YAI: syntax for preset locals without using dummy args with d efaults
Delaney, Timothy
tdelaney at avaya.com
Sun Jan 12 20:09:53 EST 2003
More information about the Python-list mailing list
Sun Jan 12 20:09:53 EST 2003
- Previous message (by thread): syntax for preset locals without using dummy args with defaults
- Next message (by thread): YAI: syntax for preset locals without using dummy args with defaults
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
> From: Skip Montanaro [mailto:skip at pobox.com] > > Bengt> Right now we often see > > Bengt> def foo(x, y=default, z=some_expression): > Bengt> ... > > This is just a performance hack and should be addressed by > other means, > e.g., more efficient access to global variables. See, for > example, PEPs 266 > and 267. I believe other not-yet--PEPped proposals have been > floated as > well. Well, in *some* circumstances (very rare) it's not just a performance hack. Specifically, if globals() goes away for some reason, you may not be able to look up the name anymore. Binding it to via a default value allows you to keep the reference. In nearly every case though, doing this is a Bad Thing(TM). The *only* case I've ever seen this is in my coverage module, where I blow everything away in order to set up a "clean" environment for the module to be covered and restore it afterwards. The module to be covered also thinks it's the __main__ module ... ;) Plus the default values are *also* a performance hack. Tim Delaney
- Previous message (by thread): syntax for preset locals without using dummy args with defaults
- Next message (by thread): YAI: syntax for preset locals without using dummy args with defaults
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-list mailing list