[Python-3000] PEP Parade (original) (raw)
Phillip J. Eby pje at telecommunity.com
Tue May 1 22:08:02 CEST 2007
- Previous message: [Python-3000] PEP Parade
- Next message: [Python-3000] PEP Parade
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
At 12:14 PM 5/1/2007 -0700, Guido van Rossum wrote:
Suppose you couldn't assign to class of a function (that's too messy to deal with in CPython) and you couldn't assign to its code either. What proposed functionality would you lose?
The ability to overload any function, without having to track down all the places it's already been imported or otherwise saved, and change them to point to a new function or a non-function object.
How would you ideally implement that functionality if you had the ability to modify CPython in other ways? (I'm guessing you'd want to add some functionality to function objects; what would that functionality have to do?)
Hm... well, in PyPy they have a "become" feature (I don't know if it's a mainline feature or not) that allows you to say, "replace object A with object B, wherever A is currently referenced". Then the replacement object (GF implementation) needn't even be a function.
A narrower feature, however, more specific to functions, would just be some way to redirect or guard the function's actual execution. For example, if function objects had a writable call attribute, that would be invoked in place of the normal behavior. (Assuming there was a way to save the old call or make a copy of the function before it was modified.)
I really just need a way to make calling the function do something different from what it normally would -- and ideally this should be in such a way that I could still invoke the function's original behavior. (So it can be used as the default method when nothing else matches, or the least-specific fallback method.)
- Previous message: [Python-3000] PEP Parade
- Next message: [Python-3000] PEP Parade
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]