Re: [Python-3000] Removing __del__

2006-09-26 Thread Nick Coghlan
Giovanni Bajo wrote: > It would require some effort to make weakref finalizers *barely* as usable > as __del__, and will absolutely not solve the problem per-se: the user will > still have to pay attention and understand the hoops (different kind of > hoops, but still hoops). So, why do we not spen

Re: [Python-3000] Removing __del__

2006-09-26 Thread Ron Adam
This was bit too brief I think... Ron Adam wrote: > How about...? (This isn't an area I'm real familiar with.) > > > Replace __del__ with: > > a __final__ method and a __finalized__ flag. (or other equivalent names) The __final__ method would need to be explicitly called, and the __fina

Re: [Python-3000] Removing __del__

2006-09-26 Thread Greg Ewing
Giovanni Bajo wrote: > I assert that they hide bugs much better than > __del__ does (it's pretty easy to find an offending __del__ by looking at > gc.garbage, It should be feasible to modify the cyclic GC to detect groups of objects that are only being kept alive by references from the finalizer l

Re: [Python-3000] Removing __del__

2006-09-26 Thread Marcin 'Qrczak' Kowalczyk
"Tim Peters" <[EMAIL PROTECTED]> writes: > Read Modules/gc_weakref.txt for the gory details. "It's a feature of Python's weakrefs too that when a weakref goes away, the callback (if any) associated with it is thrown away too, unexecuted." I disagree with this choice. Doesn't it prevent weakrefs

Re: [Python-3000] Removing __del__

2006-09-26 Thread Giovanni Bajo
Tim Peters wrote: > [Giovanni Bajo] >> Raymond, there is one thing I don't understand in your line of >> reasoning. You say that you prefer explicit finalization, but that >> implicit finalization still needs to be supported. And for that, >> you'd rather drop __del__ and use weakrefs. But why? Yo

Re: [Python-3000] Removing __del__

2006-09-26 Thread Giovanni Bajo
Nick Coghlan wrote: >> Raymond, there is one thing I don't understand in your line of >> reasoning. You say that you prefer explicit finalization, but that >> implicit finalization still needs to be supported. And for that, >> you'd rather drop __del__ and use weakrefs. But why? You say that >> __

Re: [Python-3000] Removing __del__

2006-09-26 Thread Jim Jewett
On 9/26/06, Greg Ewing <[EMAIL PROTECTED]> wrote: > Giovanni Bajo wrote: > > I assert that they hide bugs much better than > > __del__ does (it's pretty easy to find an offending __del__ by looking at > > gc.garbage, > It should be feasible to modify the cyclic GC to > detect groups of objects tha

Re: [Python-3000] Removing __del__

2006-09-26 Thread Marcin 'Qrczak' Kowalczyk
"Giovanni Bajo" <[EMAIL PROTECTED]> writes: > Guido was proposing a solution with __del__ and CT, which > approximately worked this way: > > - When a CT is detected, any __del__ method is invoked once per > instance, in random order. This means that __del__ may attempt to use an object which has

Re: [Python-3000] Removing __del__

2006-09-26 Thread Giovanni Bajo
Jim Jewett wrote: >>> You say that __del__ is harardous, but I can't see how >>> weakrefs are less hazardous. As an implicit finalization method, >>> they live on the fragile assumption that the callback won't hold a >>> reference to the object: > >> Nope, not so. > > I think you read "live" as

Re: [Python-3000] Removing __del__

2006-09-26 Thread Jim Jewett
On 9/26/06, Marcin 'Qrczak' Kowalczyk <[EMAIL PROTECTED]> wrote: > "Giovanni Bajo" <[EMAIL PROTECTED]> writes: > > Guido was proposing a solution with __del__ and CT, which > > approximately worked this way: > > - When a CT is detected, any __del__ method is invoked once per > > instance, in rand

Re: [Python-3000] Removing __del__

2006-09-26 Thread Jim Jewett
On 9/26/06, Tim Peters <[EMAIL PROTECTED]> wrote: > [Giovanni Bajo] > > You say that __del__ is harardous, but I can't see how > > weakrefs are less hazardous. As an implicit finalization method, they live > > on > > the fragile assumption that the callback won't hold a reference to the > > objec

Re: [Python-3000] Removing __del__

2006-09-26 Thread Ron Adam
Giovanni Bajo wrote: > Since we are discussing Py3k here, I believe it is the right time to revive > this discussion. The __close__ proposal I'm backing (sumed up in this mail: > http://mail.python.org/pipermail/python-3000/2006-September/003892.html) is > pretty similar to how Guido was proposing

Re: [Python-3000] Removing __del__

2006-09-26 Thread Nick Coghlan
Giovanni Bajo wrote: > Raymond Hettinger wrote: > >> In short, __del__ should disappear not because it is useless but >> because >> it is hazardous. The consenting adults philosophy means that we don't >> put-up artificial barriers to intentional hacks, but it does not mean >> that we bait the ho

Re: [Python-3000] Removing __del__

2006-09-26 Thread Giovanni Bajo
Raymond Hettinger wrote: > In short, __del__ should disappear not because it is useless but > because > it is hazardous. The consenting adults philosophy means that we don't > put-up artificial barriers to intentional hacks, but it does not mean > that we bait the hook and leave error-prone traps

Re: [Python-3000] Removing __del__

2006-09-26 Thread Tim Peters
[Giovanni Bajo] > Raymond, there is one thing I don't understand in your line of reasoning. You > say that you prefer explicit finalization, but that implicit finalization > still > needs to be supported. And for that, you'd rather drop __del__ and use > weakrefs. But why? You say that __del__ is

Re: [Python-3000] How will unicode get used?

2006-09-26 Thread Martin v. Löwis
Paul Prescod schrieb: > There is at least one big difference between surrogate pairs and > decomposed characters. The user can typically normalize away > decompositions. How do you normalize away decompositions in a language > that only supports 16-bit representations? I don't see the problem: Yo

Re: [Python-3000] How will unicode get used?

2006-09-26 Thread Marcin 'Qrczak' Kowalczyk
"Martin v. Löwis" <[EMAIL PROTECTED]> writes: > It is somewhat tricky to implement a normalization algorithm in > UTF-16, since you must combine surrogate pairs first in order to > find out what the canonical decomposition of the code point is; > but it's just more code, and no problem in principl

Re: [Python-3000] How will unicode get used?

2006-09-26 Thread Martin v. Löwis
Fredrik Lundh schrieb: >> I believe it would noticeably simplify the implementation if there is > > only a single internal representation. > > and I, wearing my string algorithm implementor hat, tend to disagree > with that. writing source code that can be compiled into efficient code > for mu

Re: [Python-3000] How will unicode get used?

2006-09-26 Thread Paul Prescod
I misspoke. I meant to ask: "How do you normalize away surrogate pairs in UTF-16?" It was a rhetorical question. The point was just that decomposed characters can be handled by implicit or explicit normalization. Surrogate pairs can only be similarly normalized away if your model allows you to repr

Re: [Python-3000] Removing __del__

2006-09-26 Thread Greg Ewing
Marcin 'Qrczak' Kowalczyk wrote: > "It's a feature of Python's weakrefs too that when a weakref goes > away, the callback (if any) associated with it is thrown away too, > unexecuted." > > I disagree with this choice. Doesn't it prevent weakrefs to be used as > finalizers? No, it's quite possibl

Re: [Python-3000] Removing __del__

2006-09-26 Thread Greg Ewing
Jim Jewett wrote: > Given this complexity, what advantage would it have over __del__, let > alone __close__? It wouldn't constitute an attractive nuisance, since it would force you to think about which pieces of information the finalizer really needs. This is something you need to do anyway if yo

Re: [Python-3000] Removing __del__

2006-09-26 Thread Greg Ewing
Giovanni Bajo wrote: > Is that easier or harder to detect such a cycle, compared to accidentally > adding a reference to self (through implicit nested scopes, or bound > methods) in the finalizer callback? I would put a notice in the docs strongly recommending that only global functions be regist

Re: [Python-3000] Removing __del__

2006-09-26 Thread Greg Ewing
Nick Coghlan wrote: > the weakref (WR) and the callback (CB) are in a > cycle with each other, so even after CB is invoked and removes WR from the > global list of finalizers, the two objects won't go away until the next GC > collection cycle. The CB can drop its reference to the WR when it's i

Re: [Python-3000] Removing __del__

2006-09-26 Thread Nick Coghlan
Greg Ewing wrote: >>> # Use closure to get at weakref to allow direct invocation >>> # This creates a cycle, so this approach relies on cyclic GC >>> # to clean up the finalizer objects! > > This implementation is broken. There's no need > to create any such cycle. I know,