query: `is_*_namespace`: input must be hashable?

Open
#421 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
45/100
Issue type
Bug
Clarity
Needs clarification
Activity status
Quiet
Tech stack
python
Domain
data

Research direction

Read array_api_compat/common/helpers.py around lines 190 and 340-341, then check Python's lru_cache hashability requirements for module arguments and the isnamespace and is_array call paths. Done means establishing whether the current casts and cached calls are valid, then documenting the required correction or confirming no change is needed.

Written by the indexing model from the issue text.

Description

The lru_cache docstring says:

Arguments to the cached function must be hashable.

But functions like

https://github.com/data-apis/array-api-compat/blob/946994733b8119b827c878ad71397823245ab75d/array_api_compat/common/_helpers.py#L340-L341

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: https://github.com/data-apis/array-api-compat/blob/946994733b8119b827c878ad71397823245ab75d/array_api_compat/common/_helpers.py#L190-L191

cc @crusaderky

Dominant language
Python
Stars
131
Forks
49
Avg merge
2d 8h
Merged PRs (30d)
6

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from data-apis/array-api-compat

All issues in data-apis/array-api-compat

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.