Skip to content

Adds cache option to remap and use in research#394

Merged
mahmoud merged 1 commit intomahmoud:masterfrom
salotz:fix-393
Jan 28, 2026
Merged

Adds cache option to remap and use in research#394
mahmoud merged 1 commit intomahmoud:masterfrom
salotz:fix-393

Conversation

@salotz
Copy link
Contributor

@salotz salotz commented Jan 28, 2026

There is a mismatch between the caching of transformed objects in the remap function and the need for research to traverse all sub trees. For most values this is inconsequential (like atomic ints, etc.) but for small tuples (e.g. ("hello",)) these get compiled as the same value and return the same id(...). In remap these get cached and never get enter called on them and thus the hooks for research to return the values never gets called.

In this fix an option to disable/enable the cache is introduced to the remap function which simply disables using transformed values from the cache. Then in the research function caching is turned off.

The existing remap behavior is maintained as caching by default is turned on.

fixes: #393

There is a mismatch between the caching of transformed objects in the
`remap` function and the need for `research` to traverse all sub
trees. For most values this is inconsequential (like atomic ints,
etc.) but for small tuples (e.g. `("hello",)`) these get compiled as
the same value and return the same `id(...)`. In `remap` these get
cached and never get `enter` called on them and thus the hooks for
`research` to return the values never gets called.

In this fix an option to disable/enable the cache is introduced to the
`remap` function which simply disables using transformed values from
the cache. Then in the `research` function caching is turned off.

The existing `remap` behavior is maintained as caching by default is
turned on.

fixes: mahmoud#393
@mahmoud
Copy link
Owner

mahmoud commented Jan 28, 2026

Ohhh, that's a good find, and well-explicated, too. Appreciate the test and keeping the PR minimal.

@mahmoud mahmoud merged commit 1737473 into mahmoud:master Jan 28, 2026
11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bug: research fails to traverse identical small tuples.

2 participants

Comments