Trapping numeric operators
John Dell'Aquila
dellaq at ml1.net
Fri Oct 22 13:41:05 EDT 2004
The lambda wrapper does impose the overhead of an extra function call:
classdict[magicName] = (
lambda self, other=None, name=magicName, op=op, fn=fn:
fn(self, other, name, op)
)
I could eliminate that by stubbing out the closure and inserting the
code block directly into it:
stub = lambda self, other=None, name=magicName, op=op: self
stub.func_code = fn.func_code
classdict[magicName] = stub
What do folks think -- useful trick or too squirrelly to countenance?
More information about the Python-list
mailing list