Skip to content

query: is_*_namespace: input must be hashable? #421

Description

@lucascolley

The lru_cache docstring says:

Arguments to the cached function must be hashable.

But functions like

@lru_cache(100)
def is_cupy_namespace(xp: Namespace) -> bool:

take modules as arguments, which are not hashable.

Is this a problem? The is_*_array functions currently cast args to Hashable before calling another lru_cache-wrapped function:

cls = cast(Hashable, type(x))
return _issubclass_fast(cls, "ndonnx", "Array")

cc @crusaderky

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions