Path: csiph.com!eternal-september.org!feeder.eternal-september.org!mx02.eternal-september.org!.POSTED!not-for-mail From: Marko Rauhamaa Newsgroups: comp.lang.python Subject: Re: The Cost of Dynamism (was Re: Pyhon 2.x or 3.x, which is faster?) Date: Sat, 12 Mar 2016 20:07:47 +0200 Organization: A noiseless patient Spider Lines: 26 Message-ID: <87vb4refik.fsf@elektro.pacujo.net> References: <87h9gcxkd3.fsf@elektro.pacujo.net> <87shzvgbhq.fsf@elektro.pacujo.net> <56e44a4e$0$1614$c3e8da3$5496439d@news.astraweb.com> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: mx02.eternal-september.org; posting-host="b7cb1518d23ec19d482dcc9c31d30fdd"; logging-data="30221"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19LBqmj9o2fQKw1ECpAOjyw" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.5 (gnu/linux) Cancel-Lock: sha1:GIH/FY2Kh+9w5zEKZ7SR7jpzZFw= sha1:iGAbXkjPJfyWLJfBbZGpdQsSBSw= Xref: csiph.com comp.lang.python:104720 BartC : > 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