Re: [Python-Dev] PEP 416: Add a frozendict builtin type

2012-03-21 Thread Guido van Rossum
To close the loop, I've rejected the PEP, adding the following rejection notice: I'm rejecting this PEP. A number of reasons (not exhaustive): * According to Raymond Hettinger, use of frozendict is low. Those that do use it tend to use it as a hint only, such as declaring global or

Re: [Python-Dev] PEP 416: Add a frozendict builtin type

2012-03-21 Thread Victor Stinner
2012/3/22 Guido van Rossum gu...@python.org: To close the loop, I've rejected the PEP, adding the following rejection notice: I'm rejecting this PEP. (...) Hum, you may specify who is I in the PEP. Victor ___ Python-Dev mailing list

Re: [Python-Dev] PEP 416: Add a frozendict builtin type

2012-03-21 Thread Victor Stinner
On the other hand, exposing the existing read-only dict proxy as a built-in type sounds good to me.  (It would need to be changed to allow calling the constructor.) I wrote a small patch to implement this request: http://bugs.python.org/issue14386 I also opened the following issue to support

Re: [Python-Dev] PEP 416: Add a frozendict builtin type

2012-03-10 Thread Victor Stinner
Le 01/03/2012 14:49, Paul Moore a écrit : Just avoid using the term immutable at all: You right, I removed mention of mutable/immutable from the PEP. Victor ___ Python-Dev mailing list Python-Dev@python.org

Re: [Python-Dev] PEP 416: Add a frozendict builtin type

2012-03-04 Thread Victor Stinner
Is your implementation (adapted to a standalone type) something you could put up on the cheeseshop? Short answer: no. My implementation (attached to the issue #14162) reuses most of private PyDict functins which are not exported and these functions have to be modified to accept a frozendict as

Re: [Python-Dev] PEP 416: Add a frozendict builtin type

2012-03-03 Thread Victor Stinner
Le 29/02/2012 19:21, Victor Stinner a écrit : Rationale = (...) Use cases of frozendict: (...) I updated the PEP to list use cases described in the other related mailing list thread. --- Use cases: * frozendict lookup can be done at compile time instead of runtime because the

Re: [Python-Dev] PEP 416: Add a frozendict builtin type

2012-03-03 Thread Eric Snow
On Sat, Mar 3, 2012 at 4:11 PM, Victor Stinner victor.stin...@gmail.com wrote: Le 29/02/2012 19:21, Victor Stinner a écrit : Rationale = (...) Use cases of frozendict: (...) I updated the PEP to list use cases described in the other related mailing list thread. --- Use cases:

Re: [Python-Dev] PEP 416: Add a frozendict builtin type

2012-03-01 Thread Victor Stinner
Rationale = A frozendict mapping cannot be changed, but its values can be mutable (not hashable). A frozendict is hashable and so immutable if all values are hashable (immutable). The wording of the above seems very unclear to me. Do you mean A frozendict has a constant set of

Re: [Python-Dev] PEP 416: Add a frozendict builtin type

2012-03-01 Thread Victor Stinner
An immutable mapping can be implemented using frozendict::     class immutabledict(frozendict):         def __new__(cls, *args, **kw):             # ensure that all values are immutable             for key, value in itertools.chain(args, kw.items()):                 if not isinstance(value,

Re: [Python-Dev] PEP 416: Add a frozendict builtin type

2012-03-01 Thread Victor Stinner
Rationale = A frozendict mapping cannot be changed, but its values can be mutable (not hashable). A frozendict is hashable and so immutable if all values are hashable (immutable). The wording of the above seems very unclear to me. Do you mean A frozendict has a constant set of

Re: [Python-Dev] PEP 416: Add a frozendict builtin type

2012-03-01 Thread Paul Moore
On 1 March 2012 12:08, Victor Stinner victor.stin...@gmail.com wrote: New try: A frozendict is a read-only mapping: a key cannot be added nor removed, and a key is always mapped to the same value. However, frozendict values can be mutable (not hashable). A frozendict is hashable and so

[Python-Dev] PEP 416: Add a frozendict builtin type

2012-02-29 Thread Victor Stinner
As requested, I create a PEP and a related issue: http://www.python.org/dev/peps/pep-0416/ http://bugs.python.org/issue14162 The PEP 416 is different from my previous propositions: frozendict values can be mutable and dict doesn't inherit from frozendict anymore. But it is still possible to use

Re: [Python-Dev] PEP 416: Add a frozendict builtin type

2012-02-29 Thread David Malcolm
On Wed, 2012-02-29 at 19:21 +0100, Victor Stinner wrote: As requested, I create a PEP and a related issue: http://www.python.org/dev/peps/pep-0416/ [...snip...] Rationale = A frozendict mapping cannot be changed, but its values can be mutable (not hashable). A frozendict is

Re: [Python-Dev] PEP 416: Add a frozendict builtin type

2012-02-29 Thread Eli Bendersky
Rationale = A frozendict mapping cannot be changed, but its values can be mutable (not hashable). A frozendict is hashable and so immutable if all values are hashable (immutable). The wording of the above seems very unclear to me. Do you mean A frozendict has a constant set

[Python-Dev] PEP 416: Add a frozendict builtin type

2012-02-29 Thread Jim J. Jewett
In http://mail.python.org/pipermail/python-dev/2012-February/117113.html Victor Stinner posted: An immutable mapping can be implemented using frozendict:: class immutabledict(frozendict): def __new__(cls, *args, **kw): # ensure that all values are immutable