[Python-Dev] frozendict (was: Possible patch for functools partial...) (original) (raw)
Yaniv Aknin yaniv at aknin.name
Sun May 16 03:55:14 CEST 2010
- Previous message: [Python-Dev] buildbot svn exceptions again...
- Next message: [Python-Dev] frozendict (was: Possible patch for functools partial...)
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
> So I'm thinking either we make an > immutable/hashable dict while we're at it, or store the keyword > arguments as a tuple (which guarantees immutability), and only > convert them back to a dict when you want to call the partial object > (simpler, slower). I'd support an immutable dict. [...]
I've set out to implement a frozendict (like frozenset) for use to store functools.keywords' attribute, and quickly realized I didn't think of an obvious flaw in that idea. A frozenset will only accept hashable members, but a frozendict can't afford this luxury for its values.
I'm not sure how should I go about handling that, if at all. Should I implement a frozendict which will remain unhashable but support equality testing like a regular dict? A frozendict that is only hashable if all its values are hashable, like a tuple? Is the whole notion of a frozendict worthy, given this limitation?
I'd be happy to hear python-dev's guidance on this.
Cheers,
- Yaniv -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://mail.python.org/pipermail/python-dev/attachments/20100516/c8fd32eb/attachment.html>
- Previous message: [Python-Dev] buildbot svn exceptions again...
- Next message: [Python-Dev] frozendict (was: Possible patch for functools partial...)
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]