A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://mail.python.org/pipermail/python-dev/2006-January/059512.html below:

[Python-Dev] Draft proposal: Implicit self in Python 3.0

[Python-Dev] Draft proposal: Implicit self in Python 3.0Thomas Wouters thomas at xs4all.net
Sun Jan 8 17:26:59 CET 2006
On Sun, Jan 08, 2006 at 08:09:22AM -0800, Ralf W. Grosse-Kunstleve wrote:
> --- Thomas Wouters <thomas at xs4all.net> wrote:
> > The main difference isn't the lookup of 'self', it's the attribute retrieval
> > of 'x' from 'self'.

> I see. Thanks!
> If you put 'self' into a special category (with corresponding C code), couldn't
> you use the same "indexing" tricks as for local variables and make 'self.x'
> just as fast as 'x'?

No need to make 'self' magical for that. You do, however, need to make the
*object* magical for that. It works for local namespaces because the Python
compiler knows exactly which names are local and which aren't. There are two
cases where the compiler can't know for sure (using 'exec' without 'in' and
using 'from module import *') and in those cases, Python doesn't optimize
local variable access all the way. This all won't work for objects and their
attributes because too much is possible at runtime for the current compiler
to handle.

The compiler could, of course, check everything in the whole program,
keeping track of what could possibly adjust which attributes of what object
where. That would be 'type inferencing' and has been (and is being, I guess)
attempted by various people in various projets. However, if your compiler is
so smart, it won't have _any_ problems taking an exlicit self into account :)

-- 
Thomas Wouters <thomas at xs4all.net>

Hi! I'm a .signature virus! copy me into your .signature file to help me spread!
More information about the Python-Dev mailing list

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4