Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion marimo/_plugins/stateless/inspect.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

import html
import inspect as inspect_
from functools import lru_cache

from marimo._output.builder import h
from marimo._output.formatting import as_html
Expand Down Expand Up @@ -422,7 +423,7 @@ def _render_attribute_row(

def _format_method(name: str, method: object, docs: bool) -> str:
try:
sig = inspect_.signature(method) # type: ignore
sig = _cached_signature(method) # type: ignore
if inspect_.iscoroutinefunction(method):
display = f"async def {name}{sig}"
else:
Expand Down Expand Up @@ -481,3 +482,8 @@ def _render_value_inline(value: object) -> str:
html.escape(value_str),
style="font-family: monospace; font-size: 0.75rem;",
)


@lru_cache(maxsize=128)
def _cached_signature(method):
return inspect_.signature(method)