Overwriting / reassigning instance / garbage collection?
Peter Hansen
peter at engcorp.com
Thu Oct 30 19:02:18 EST 2003
Ken Godee wrote:
>
> > try:
> > while 1:
> > q1.get(0)
> > except Queue.Empty:
> > pass
[snip]
> >
> yes, I understand this.
> and that's why I'm wondering if de-referencing the instance
> as below would work and that the old address space would
> get garabage collected. This would then happen in a fraction
> of the time that it might take the while statement to empty
> the queue, if ever.
Ah, there's your problem. You're trying to optimize before you have
a working solution *or* actual measurements showing a performance
problem.
My strong suggestion is write a little clearQueue() routine as
above, and call that, and only worry about the whole thing if you
ever notice a serious performance issue. Most likely you won't.
-Peter
More information about the Python-list
mailing list