Tuple assignment and generators?

vdrab stijndesaeger at gmail.com
Fri May 5 08:23:24 EDT 2006


> Are you telling us that you *had* read that doc,
> and tripped because it says "depending on the implementation",
> when it should say "at the choice of the implementation" ?

no.
let's see, where to start ... ?
let's say there's a certain property P, for the sake of this loooong
discussion, something
more or less like a class or type's property of "having immutable
values, such that any instance with value X has a single, unique
representation in memory and any two instantiations of objects with
that value X are in fact references to the same object".

Then, for example, python strings have property P whereas python lists
do not:

>>> x = "test"
>>> y = "test"
>>> x is y
True
>>> x = []
>>> y = []
>>> x is y
False
>>>

Now, as it turns out, whether or not python integers have property P
_depends_on_their_value_.
For small values, they do. For large values they don't. Yes, I
understand about the interpreter optimization. I didn't know this, and
I find it neither evident nor consistent. I don't think the above post
explains this, regardless of how you read "implementation".

In fact, the whole string of replies after my initial question reminded
me of something I read not too long ago, but didn't quite understand at
the time.
source :
http://www.oreillynet.com/ruby/blog/2006/01/a_little_antiantihype.html

'''
Pedantry: it's just how things work in the Python world. The status
quo is always correct by definition. If you don't like something, you
are incorrect. If you want to suggest a change, put in a PEP,
Python's equivalent of Java's equally glacial JSR process. The
Python FAQ goes to great lengths to rationalize a bunch of broken
language features. They're obviously broken if they're frequently
asked questions, but rather than 'fessing up and saying "we're
planning on fixing this", they rationalize that the rest of the world
just isn't thinking about the problem correctly. Every once in a
while some broken feature is actually fixed (e.g. lexical scoping), and
they say they changed it because people were "confused". Note that
Python is never to blame.
'''

taking this rant with the proverbial grain of salt, I did think it was
funny.

Anyway, thanks for all the attempts to show me.
I will get it in the end. 
v.




More information about the Python-list mailing list