Identified in #67 — flagged as cleanup in the "Explicitly out of scope" section.
Current state
_PASSTHROUGH_NAMES (in src/whest/_ndarray.py) holds the original numpy callables that should bypass __array_function__ entirely because they're zero-FLOP queries. Today the set covers shape / type queries:
_PASSTHROUGH_NAMES = (
"ndim", "shape", "size",
"result_type", "can_cast", "min_scalar_type",
"promote_types", "find_common_type", "mintypecode",
"array_equal",
)
Missing: may_share_memory, shares_memory, byte_bounds. They're zero-FLOP memory-layout queries that currently work because the protocol path strips inputs and dispatches; routing them through the strip path is wasteful.
Reproducer
import numpy as np, whest as we
A = we.random.randn(3, 3)
np.may_share_memory(A, A) # works, but enters __array_function__ unnecessarily
Suggested fix
Add the three names to _PASSTHROUGH_NAMES and update the eager _INITIAL_PASSTHROUGH = _build_passthrough() capture. One-line addition each. Add a short test in tests/test_array_protocols.py that asserts these calls no longer enter __array_function__ (e.g. by patching _get_array_function_dispatch and asserting it's not called).
Acceptance criteria
- The three names added to
_PASSTHROUGH_NAMES.
- Test pinning that they don't dispatch through
__array_function__.
Related
Identified in #67 — flagged as cleanup in the "Explicitly out of scope" section.
Current state
_PASSTHROUGH_NAMES(insrc/whest/_ndarray.py) holds the original numpy callables that should bypass__array_function__entirely because they're zero-FLOP queries. Today the set covers shape / type queries:Missing:
may_share_memory,shares_memory,byte_bounds. They're zero-FLOP memory-layout queries that currently work because the protocol path strips inputs and dispatches; routing them through the strip path is wasteful.Reproducer
Suggested fix
Add the three names to
_PASSTHROUGH_NAMESand update the eager_INITIAL_PASSTHROUGH = _build_passthrough()capture. One-line addition each. Add a short test intests/test_array_protocols.pythat asserts these calls no longer enter__array_function__(e.g. by patching_get_array_function_dispatchand asserting it's not called).Acceptance criteria
_PASSTHROUGH_NAMES.__array_function__.Related
_PASSTHROUGH_NAMESand called this out as a cleanup follow-up.