Skip to content

Caching the tuple hash calculation speeds up some code significantly #131525

Closed

Description

@mdboom

Proposal:

Back in 2013, it was determined that caching the result of tuple_hash did not have any significant speedup.

However, a lot has changed since then, and in a recent experiment to add a tuple hash cache back in, the mdp benchmark increased by 86%.

Admittedly, there was no measurable improvement on any other benchmark, but it also seems to have no downside, including for memory usage when measured with max_rss.

Has this already been discussed elsewhere?

No response given

Links to previous discussion of this feature:

  • [ ]

Linked PRs

Activity

  1. self-assigned this
    on Mar 20, 2025
  2. added 2 commits that reference this issue on Mar 20, 2025
  3. rhettinger commented on Mar 20, 2025

    @rhettinger
    Contributor

    This would nicely simplify and speed-up the pure python implementation of lru_cache. The _HashedSeq class would no longer be needed, and a plain tuple would suffice.

  4. added a commit that references this issue on Mar 27, 2025
  5. added 2 commits that reference this issue on Mar 31, 2025
  6. added a commit that references this issue on Mar 31, 2025
  7. added a commit that references this issue on Apr 1, 2025
  8. erlend-aasland commented on May 14, 2025

    @erlend-aasland
    Contributor

    Is there more work to be done here?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

interpreter-core(Objects, Python, Grammar, and Parser dirs)performancePerformance or resource usagetype-featureA feature request or enhancement

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions