how to count lines in a file ?

Alex Martelli aleax at aleax.it
Fri Jul 26 06:36:56 EDT 2002


Neil Hodgson wrote:

> Alex Martelli:
> 
>> One thought I've toyed with, at times, is to have the optional
>> ability to mark a few objects as _requiring_ stricter finalization
>> semantics than the run-of-the-mill kinds of objects.  E.g., files
>> could be marked that way.
> 
>    Some of the history behind .NET not having deterministic finalization
> even for a subset of objects:
> http://www.managedworld.com/articles/0003/article.aspx

VERY good reference, and an excellent article too -- thanks!  If
nothing else, I can rub it in somebody's face next time said
somebody says some absurdity about the abilities of MS's techies
(some of them ARE really good, as this article shows:-).


Note that .NET does make slightly stronger promises for finalizers
than Java and other GC systems, even though, as the article's author
notes, .NET's docs are rather cautious (one could say wishy-washy)
about it, given (I surmise) the difficulty of defining what a "well
behaved" program is in a distributed, networked environment.  __del__
in Python (at least in general, i.e., considering Jython too) is
far weaker than in .NET, *and* has the further trouble of impeding
GC when it occurs in cycles.  Thus, it might well be preferable to
avoid a __del__ in Python where in an equivalent .NET case you
would decide to write a finalizer "just in case".


It's interesting to notice that the reason they gave up (prematurely)
on deterministically-finalizing just SOME objects was a (doomed)
attempt to preserve VB6's semantics.  Eventually VB6 semantics
went by the wayside anyway, but in the meantile deterministic
finalization for just SOME objects had been abandoned.  The author
IS hinting that they're thinking about it again for the future:-).

It also seems to me they haven't considered the specific approach
that seems most feasible to me: do it per-object, not per-class,
AND have an "object wrapped in a single-owner" only hand out WEAK
references (proxies).  Maybe too explicit for their tastes:-).

However, their proposed "using" statement IS exactly what I've
also been dreaming about to collapse deuced trees of try/finally
statements (except for syntax sugar differences between C# and
Python, of course:-).  I wonder whether that's good or bad:-).


Alex




More information about the Python-list mailing list