Re: [Python-Dev] Weak Dictionary Iteration Behavior in Python 3

2008-09-14 Thread Virgil Dupras
I would also like to point out that I submitted a patch related to that a couple of months ago in: http://bugs.python.org/issue839159 But it never got any attention :( I'm not sure if it is still relevant. Virgil On 13-Sep-08, at 10:20 PM, Armin Ronacher wrote: Hi everybody, In Python

Re: [Python-Dev] Weak Dictionary Iteration Behavior in Python 3

2008-09-14 Thread Armin Ronacher
Hi, Josiah Carlson josiah.carlson at gmail.com writes: i = list(d.keys()) Obviously that doesn't solve the problem. list() consumes the generator one after another, objects can still die when the list is created. Imagine the following example which uses threads:: from time import sleep

Re: [Python-Dev] Weak Dictionary Iteration Behavior in Python 3

2008-09-14 Thread Armin Ronacher
Hi, Adam Olsen rhamph at gmail.com writes: IMO, this is a deeper problem than suggested. As far as I know, python does not (and should not) make promises as to when it'll collect object. We should expect weakrefs to be cleared at random points, and code defensively. It doesn't promise when

Re: [Python-Dev] Weak Dictionary Iteration Behavior in Python 3

2008-09-14 Thread Nick Coghlan
Armin Ronacher wrote: Speaking of atom keys() / values() / items() operations: I guess we will see more of those problems in threaded situations when people start to convert code over to Python. I've seen quite a few situations where code relays on keys() holding the interpreter lock.

Re: [Python-Dev] Weak Dictionary Iteration Behavior in Python 3

2008-09-14 Thread Georg Brandl
Nick Coghlan schrieb: Armin Ronacher wrote: Speaking of atom keys() / values() / items() operations: I guess we will see more of those problems in threaded situations when people start to convert code over to Python. I've seen quite a few situations where code relays on keys() holding the

Re: [Python-Dev] Weak Dictionary Iteration Behavior in Python 3

2008-09-14 Thread Nick Coghlan
Georg Brandl wrote: Nick Coghlan schrieb: Armin Ronacher wrote: Speaking of atom keys() / values() / items() operations: I guess we will see more of those problems in threaded situations when people start to convert code over to Python. I've seen quite a few situations where code relays on

[Python-Dev] Weak Dictionary Iteration Behavior in Python 3

2008-09-13 Thread Armin Ronacher
Hi everybody, In Python 2.x when iterating over a weak key dictionary for example, the common idom for doing that was calling dictionary.keys() to ensure that a list of all objects is returned it was safe to iterate over as a weak reference could stop existing during dict iteration which of

Re: [Python-Dev] Weak Dictionary Iteration Behavior in Python 3

2008-09-13 Thread Josiah Carlson
On Sat, Sep 13, 2008 at 1:20 PM, Armin Ronacher [EMAIL PROTECTED] wrote: Hi everybody, In Python 2.x when iterating over a weak key dictionary for example, the common idom for doing that was calling dictionary.keys() to ensure that a list of all objects is returned it was safe to iterate

Re: [Python-Dev] Weak Dictionary Iteration Behavior in Python 3

2008-09-13 Thread Scott David Daniels
Josiah Carlson wrote: On Sat, Sep 13, 2008 at 1:20 PM, Armin Ronacher wrote: Iterating over weak key dictionaries might not be the most common task but I know some situations where this is necessary. Unfortunately I can't see a way to achieve that in Python 3. i = list(d.keys()) Surely

Re: [Python-Dev] Weak Dictionary Iteration Behavior in Python 3

2008-09-13 Thread Josiah Carlson
On Sat, Sep 13, 2008 at 5:21 PM, Scott David Daniels [EMAIL PROTECTED] wrote: Josiah Carlson wrote: On Sat, Sep 13, 2008 at 1:20 PM, Armin Ronacher wrote: Iterating over weak key dictionaries might not be the most common task but I know some situations where this is necessary.

Re: [Python-Dev] Weak Dictionary Iteration Behavior in Python 3

2008-09-13 Thread Adam Olsen
On Sat, Sep 13, 2008 at 2:20 PM, Armin Ronacher [EMAIL PROTECTED] wrote: Hi everybody, In Python 2.x when iterating over a weak key dictionary for example, the common idom for doing that was calling dictionary.keys() to ensure that a list of all objects is returned it was safe to iterate