The Cost of Dynamism (was Re: Pyhon 2.x or 3.x, which is faster?)

Marko Rauhamaa marko at pacujo.net
Sat Mar 12 13:07:47 EST 2016


BartC <bc at freeuk.com>:
> No it's very easy. In Python terms:
>> def f(): return "One"
> def g(): return "Two"
>> h=f
>> h() returns "One". Later you do h=g, and h() returns "Two". No need
> for f and g themselves to be dynamic. h just needs to be a variable.

Well, what do you make of this:
 >>> def f(): return 1
 ...
 >>> g = f
 >>> def f(): return 2
 ...
 >>> g()
 1
 >>> f()
 2
Marko


More information about the Python-list mailing list

AltStyle によって変換されたページ (->オリジナル) /