Paulo da Silva wrote: > Hi all. > > What is the fastest implementation of the following code? > > def g(p): > ... > return something > > def f1(p="p1"): > return g(p) > > def f2(p="p2"): > return g(p)
>>> def g(p): return p.upper()
...
>>> def f1(): pass
...
>>> f1.__code__ = g.__code__
>>> f1.__defaults__ = ("p1",)
>>> f1()
'P1'
Not recommended ;)
--
https://mail.python.org/mailman/listinfo/python-list
