Skip to content

[mypyc] feat: make frozenset literal compilation deterministic [1/1]#19965

Draft
BobTheBuidler wants to merge 11 commits into
python:masterfrom
BobTheBuidler:patch-7
Draft

[mypyc] feat: make frozenset literal compilation deterministic [1/1]#19965
BobTheBuidler wants to merge 11 commits into
python:masterfrom
BobTheBuidler:patch-7

Conversation

@BobTheBuidler

Copy link
Copy Markdown
Contributor

This PR makes the process of encoding frozenset literals deterministic by sorting the items before encoding.

@BobTheBuidler BobTheBuidler changed the title [mypyc] feat: make frozenset literal compilation deterministic [mypyc] feat: make frozenset literal compilation deterministic [1/1] Oct 1, 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.

This is a good idea -- non-deterministic generated code is a significant problem.

Comment thread mypyc/codegen/literals.py Outdated
Comment thread mypyc/codegen/literals.py Outdated

def encoded_frozenset_values(self) -> list[str]:
return self._encode_collection_values(self.frozenset_literals)
def sort_frozenset_recursive(frozen: frozenset[object]) -> list[object]:

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

maybe I move this even further up and sort them as they're added?

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.

2 participants