Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #10797
| Date | 2011-08-03 12:00 +0200 |
|---|---|
| From | Thomas Jollans <t@jollybox.de> |
| Subject | Re: Early binding as an option |
| References | <CAPTjJmpWN1Tq-46UoHjh_-q9ahkivTWmLJR3_eF9iThHwXQnhA@mail.gmail.com> <j19mbp$985$1@dough.gmane.org> <CAPTjJmr8mjYKTYu9EdKc-QRaFfSwH0rbVdAhnW-ysfvOZujJqQ@mail.gmail.com> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.1830.1312365594.1164.python-list@python.org> (permalink) |
On 03/08/11 00:08, Chris Angelico wrote:
> With the local-variable-snapshot technique ("len = len"), can anything
> be optimized, since the parser can guarantee that nothing ever
> reassigns to it? If not, perhaps this would be a place where something
> might be implemented:
> [...]
Yes, it can. The parser can know when it is reassigned to just by
looking at the one function, and even if it didn't, or if it were
reassigned, it wouldn't make much of a difference because the
interpreter would still only have to fetch one of a set of locals known
at compile time, which can be (is? I'm not sure) as simple as an array
lookup: two pointers being dereferences instead of one.
Chris Rebert raises a very important point though: Python dynamic
namespaces make optimising variable lookup comparatively difficult, but
not impossible: good JavaScript JITs are smart enough, so a good Python
JIT could be as well.
Thomas
Back to comp.lang.python | Previous | Next | Find similar | Unroll thread
Re: Early binding as an option Thomas Jollans <t@jollybox.de> - 2011-08-03 12:00 +0200
csiph-web