[Python-Dev] Scoping vs augmented assignment vs sets (Re: 'fast locals' in Python 2.5)

Boris Borcic bborcic at gmail.com
Wed Jun 14 13:12:09 CEST 2006


Josiah Carlson wrote:

> You seem to not realize that these different use-cases.  Your new
> example involves a global variable that is *shared* among everyone that
> knows  about this particular module.  It also is repaired by a simple
> insertion of 'global freebits' at the beginning of the search function. 

My point here : a simple repair, and by a statement that amounts to a compiler 
directive with no other effect than obtaining my intent in bytecodes, so that 
"all other things being equal" comparisons of code versions remain possible 
(recall that I was studying the impact on working code of adopting sets - 
including performance).

> The closure/class example is merely a method of encapsulating state,
> which I find easier to define, describe, and document than the closure
> version.

Your priviledge of course (and I am not saying it is misguided, although I would 
in particular argue that the matter gets debatable in the low LOC-count limit). 
(I am also wondering about performance comparisons).

> Back in February, there was a discussion about allowing people to
> 'easily' access and modify variables defined in lexically nested scopes,
> but I believed then, as I believe now, that such attempted uses of
> closures are foolish when given classes.   Given the *trivial* conversion
> of your closure example to a class, and my previous comments on closures
> "I find their use rarely, if ever, truely elegant, [...] more like
> kicking a puppy for barking: [...] there are usually better ways of
> dealing with the problem (don't kick puppies for barking and don't use
> closures).", you are not likely to find me agreeing with you about
> augmented assignment and/or lexically nested scopes.

I see. Thanks for the background. Background for backround, let me just say that 
python hadn't yet grown a lambda when I first played with it. May I read your 
last statement as acknowledging that I am not so much asking for a door to be 
created, than asking for a naturally builtin door, not to be locked by special 
efforts ?

Regards, Boris Borcic
--
"On naît tous les mètres du même monde"



More information about the Python-Dev mailing list