Home
Reading
Searching
Subscribe
Sponsors
Statistics
Posting
Contact
Spam
Lists
Links
About
Hosting
Filtering
Features Download
Marketing
Archives
FAQ
Blog
 
Gmane
From: Stefan Behnel <stefan_ml-KjMAwuNBv5izQB+pC5nmwQ <at> public.gmane.org>
Subject: Re: [Cython] PEP 3135 -- New Super
Newsgroups: gmane.comp.python.cython.devel
Date: Tuesday 5th July 2011 07:00:49 UTC (over 5 years ago)
Vitja Makarov, 05.07.2011 08:21:
> I was thinking about implementing new super() with no arguments.

Please do :)

If you start working on it, please assign the ticket to you:

http://trac.cython.org/cython_trac/ticket/696


> The problem is where to store __class__, I see two options here:
>
> 1. Add func_class member to CyFunction, this way __class__ will be
> private and not visible for inner functions:
> 2. Put it into closure

The second option has the advantage of requiring the field only when 
super() is used, whereas the first impacts all functions.

I would expect that programs commonly have a lot more functions than 
specifically methods that use a no-argument call to super(), so this may 
make a difference.

OTOH, not all methods have a closure, so creating one just to store the 
"__class__" field is very wasteful, in terms of both runtime and memory 
overhead. A lot more wasteful than paying 8 bytes of memory for each 
function, with no additional time overhead.


> And I don't think that __class__ should be use somewhere outside super()

Agreed. CPython simply uses a compile time heuristic ("is there a function 
call to something global named 'super'?") when creating this field, so it's

strictly reserved for this use case.

BTW, I like the irony in the fact that CPython essentially gives Cython 
semantics to the "super" builtin here, by (partially) evaluating it at 
compile time.

Stefan
 
CD: 3ms