Skip to content

[mypyc] Improve support for frozenset - #18571

Merged
JukkaL merged 3 commits into
python:masterfrom
cdce8p:mypyc-frozenset
Jan 31, 2025
Merged

JukkaL merged 3 commits into
python:masterfrom
cdce8p:mypyc-frozenset

Conversation

@cdce8p

@cdce8p cdce8p commented Jan 30, 2025

Copy link
Copy Markdown
Collaborator

Add optimized methods for len and contains on frozenset objects.

@cdce8p cdce8p added the topic-mypyc mypyc bugs label Jan 30, 2025

@JukkaL JukkaL left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! Frozensets are likely be used in performance critical code, so having better support for them is helpful. Left a few minor comments, overall looks good.

Comment thread mypyc/test-data/run-sets.test Resolved
Comment thread mypyc/test-data/run-sets.test Resolved
@@ -0,0 +1,536 @@
[case testNewFrozenSet]

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The irbuild tests are maybe too verbose -- they may need to be updated frequently as the details of emitter IR change. My suggestion would be to avoid some duplication and to move some thing to run tests if they don't otherwise have test coverage.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tbh for the first implementation I mostly copied the set test cases and adjusted them slightly for frozenset. Your suggestion does make sense though. Moved some of the fromIterable tests to run_sets.test.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah some of the existing IR build tests are overly verbose.

Comment thread mypyc/doc/frozenset_operations.rst Resolved
@JukkaL
JukkaL merged commit ce1be2a into python:master Jan 31, 2025
@cdce8p
cdce8p deleted the mypyc-frozenset branch January 31, 2025 16:06
x612skm pushed a commit to x612skm/mypy-dev that referenced this pull request Feb 24, 2025
Add optimized methods for `len` and `contains` on `frozenset` objects.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

topic-mypyc mypyc bugs

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants