[Python-ideas] Composition over Inheritance

Chris Angelico rosuav at gmail.com
Sat Oct 28 22:13:29 EDT 2017


On Sun, Oct 29, 2017 at 1:05 PM, Soni L. <fakedme+py at gmail.com> wrote:
> And how do you make the object creation so cheap to the point where it's
> actually practical? (quick question: does Python use a single opcode and an
> optimized codepath for method calls, or does it always create a method
> wrapper, even for immediate o.m() calls? If it's the latter then yeah I
> guess there's no reason for new syntax because it's not gonna be
> significantly slower than what we currently have...)

Python-the-language simply specifies the semantics. Different
implementations do different things. AIUI CPython 3.7 always creates a
method wrapper (using a free-list to minimize memory allocations), but
a future version might not; and PyPy's current versions have a special
opcode.

ChrisA


More information about the Python-ideas mailing list