If you are new to frozendict trend in Python, PEP stuff might be quite far down the line so don’t worry too much about it if you want to make things happen and not only write a PEP which will most likely be rejected.
So the way I understand it:
- You have a proposal to do “dict constant folding”
- For that to happen, there needs to be a functional
frozendicttype - There has been a lot of effort towards
frozendict, indicating that this is most likely a bottleneck for your idea.
So your option are:
- Using your existing implementation (or any other) to prove that constant folding delivers benefit. What are preconditions (minimum performance threshold) for
frozendictimplementation that would make “dict constant folding” worthwhile? This could be one of valuable inputs that could potentially affect potential future implementation offrozendict. Then relax and wait until/when/iffrozendictgets implemented while nudging ongoing attempts if they aren’t sufficient to extract the “dict constant folding” benefit (given you have proven that the benefit is significant enough to make effort/trouble - collected real life use cases where this would apply and benchmarked). - Start working on
frozendictin parallel to “dict constant folding” idea. This would be a bit more involved. I haven’t done any work here so don’t have much to suggest on main obstacles of “why this hasn’t happened yet”. But superficially, if community wants it and it hasn’t happened yet, then the “right” approach hasn’t been found yet - the one where desirable benefits are shining, the cost is minimised, all decisions are nailed down perfectly (e.g. naming and location) and all the best knowledge gathered so far incorporated (e.g. HAMT vsdicttradeoffs ofmemoryandcopyvsaccessperformance - which one is better forfrozendict? Why? Maybe some hybrid? Why? Maybe something else entirely?).
For (2), here are some starting points (will repeat already mentioned for completeness):
- PEP 416 – Add a frozendict builtin type | peps.python.org
- PEP 603 – Adding a frozenmap type to collections | peps.python.org
- Discussion: PEP 603: Adding a frozenmap type to collections
from _testinternalcapi import hamt- Also, some thoughts on comprehensions as expanding number of core types puts a strain on syntax. This is not necessarily related, but personally if I was to work on
frozendictI would keep an eye on that as well: