| ▲ | perrygeo 2 days ago | |||||||||||||||||||||||||
You're absolutely right: an "indirection data structure" is necessary. Freezing the data is the least interesting part - it doesn't give you any of the benefits typically associated with immutable data structures in functional languages. That's my point - Python is shipping a half solution that's being mistaken for a proper one. You think Python developers are going to roll their own HAMT on top of frozendicts? Or are they just gonna make copies? Personally, I'd just use pyrsistent which seems to get it right. | ||||||||||||||||||||||||||
| ▲ | compressedgas 3 hours ago | parent | next [-] | |||||||||||||||||||||||||
> You think Python developers are going to roll their own HAMT Python already has an HAMT implementation in use by the contextvars module. | ||||||||||||||||||||||||||
| ▲ | rented_mule 2 days ago | parent | prev | next [-] | |||||||||||||||||||||||||
It's a little early to say that "Python is shipping" anything related to this. The PEP is still in draft status and it may be modified (as it was three hours ago) or even rejected. The article says it is likely to be accepted, but that has not happened yet. That also means there is time to comment on the PEP in the discussion it links to if you'd like. | ||||||||||||||||||||||||||
| ▲ | BiteCode_dev 2 days ago | parent | prev [-] | |||||||||||||||||||||||||
pyrsistent is super slow, though. Just ran a quick benchmark:
Except at 10k+ items, batchup dates on 100K+ items or inserting 100 keys.This is rarely the case in practice, most dictionaries and dict operations are small, if you have a huge dict, you probably should be chunking your load or delegating that to infra. Not to mention pyrsistent's API is incompatible with dicts, so you can't pass it to external code without conversion. You'd better have an incredible ROI to justify that. | ||||||||||||||||||||||||||
| ||||||||||||||||||||||||||