Re: [Python-Dev] Fighting the theoretical randomness of "is" on immutables

2013-05-07 Thread Nick Coghlan
On Tue, May 7, 2013 at 6:27 PM, Armin Rigo wrote: > Hi Antoine, > > On Tue, May 7, 2013 at 8:25 AM, Antoine Pitrou wrote: >> For me, a patch that mandated general-purpose containers (list, dict, >> etc.) respect object identity would be ok. > > Thanks, that's also my opinion. > > In PyPy's approa

Re: [Python-Dev] Fighting the theoretical randomness of "is" on immutables

2013-05-07 Thread Armin Rigo
Hi Antoine, On Tue, May 7, 2013 at 8:25 AM, Antoine Pitrou wrote: > For me, a patch that mandated general-purpose containers (list, dict, > etc.) respect object identity would be ok. Thanks, that's also my opinion. In PyPy's approach, in trying to emulate CPython vs. trying to convince users th

Re: [Python-Dev] Fighting the theoretical randomness of "is" on immutables

2013-05-06 Thread Antoine Pitrou
On Mon, 06 May 2013 22:50:55 -0400 Terry Jan Reedy wrote: > > > A bytearray or a array.array may indeed store values, but a list stores > > references to > > objects. > > I said exactly that in reference to CPython. As far as I know, the same > is true of lists in every other implementation up

Re: [Python-Dev] Fighting the theoretical randomness of "is" on immutables

2013-05-06 Thread Gregory P. Smith
On Mon, May 6, 2013 at 7:50 PM, Terry Jan Reedy wrote: > On 5/6/2013 6:34 PM, Antoine Pitrou wrote: > >> On Mon, 06 May 2013 18:23:02 -0400 >> Terry Jan Reedy wrote: >> >>> >>> 'Item' is necessarily left vague for mutable sequences as bytearrays >>> also store values. The fact that Antoine's exa

Re: [Python-Dev] Fighting the theoretical randomness of "is" on immutables

2013-05-06 Thread Terry Jan Reedy
On 5/6/2013 6:34 PM, Antoine Pitrou wrote: On Mon, 06 May 2013 18:23:02 -0400 Terry Jan Reedy wrote: 'Item' is necessarily left vague for mutable sequences as bytearrays also store values. The fact that Antoine's example 'works' for bytearrays is an artifact of the caching, not a language-mand

Re: [Python-Dev] Fighting the theoretical randomness of "is" on immutables

2013-05-06 Thread Antoine Pitrou
On Mon, 06 May 2013 18:23:02 -0400 Terry Jan Reedy wrote: > > 'Item' is necessarily left vague for mutable sequences as bytearrays > also store values. The fact that Antoine's example 'works' for > bytearrays is an artifact of the caching, not a language-mandated > necessity. No, it isn't. You

Re: [Python-Dev] Fighting the theoretical randomness of "is" on immutables

2013-05-06 Thread Terry Jan Reedy
On 5/6/2013 10:20 AM, Nick Coghlan wrote: On Mon, May 6, 2013 at 11:26 PM, Antoine Pitrou wrote: Le Mon, 6 May 2013 23:18:54 +1000, Nick Coghlan a écrit : We're not going to change the language design because people don't understand the difference between "is" and "==" For sure. The definit

Re: [Python-Dev] Fighting the theoretical randomness of "is" on immutables

2013-05-06 Thread PJ Eby
On Mon, May 6, 2013 at 4:46 AM, Armin Rigo wrote: > This is clearly a language design issue though. I can't really think > of a use case that would break if we relax the requirement, but I > might be wrong. It seems to me that at most some modules like pickle > which use id()-keyed dictionaries

Re: [Python-Dev] Fighting the theoretical randomness of "is" on immutables

2013-05-06 Thread Nick Coghlan
On Mon, May 6, 2013 at 11:26 PM, Antoine Pitrou wrote: > Le Mon, 6 May 2013 23:18:54 +1000, > Nick Coghlan a écrit : >> We're not going to change the language design because people don't >> understand the difference between "is" and "==" and then wrongly blame >> PyPy for breaking their code. > >

Re: [Python-Dev] Fighting the theoretical randomness of "is" on immutables

2013-05-06 Thread Antoine Pitrou
Le Mon, 6 May 2013 23:18:54 +1000, Nick Coghlan a écrit : > > IIRC, Jython just delays calculating the object id() until it is > called, and lives with it potentially being incredibly expensive to > calculate. Is there some way PyPy can run with a model where "is" is > defined in terms of values

Re: [Python-Dev] Fighting the theoretical randomness of "is" on immutables

2013-05-06 Thread Nick Coghlan
On Mon, May 6, 2013 at 6:46 PM, Armin Rigo wrote: > This is clearly a language design issue though. I can't really think > of a use case that would break if we relax the requirement, but I > might be wrong. It seems to me that at most some modules like pickle > which use id()-keyed dictionaries

Re: [Python-Dev] Fighting the theoretical randomness of "is" on immutables

2013-05-06 Thread Terry Jan Reedy
On 5/6/2013 4:46 AM, Armin Rigo wrote: 'is' *is* well-defined. In production code, the main use of 'is' is for builtin singletons, the bool doubleton, and object instances used as sentinals. The most common use, in particular, is 'if a is None:'. For such code, the result must be independent o

[Python-Dev] Fighting the theoretical randomness of "is" on immutables

2013-05-06 Thread Armin Rigo
Hi all, In the context PyPy, we've recently seen again the issue of "x is y" not being well-defined on immutable constants. I've tried to summarize the issues and possible solutions in a mail to pypy-dev [1] and got some answers already. Having been convinced that the core is a language design i