[Import-SIG] PEP 489: Multi-phase extension module initialization; version 5
ericsnowcurrently at gmail.com
Wed May 20 17:14:37 CEST 2015
On Wed, May 20, 2015 at 5:08 AM, Petr Viktorin <encukou at gmail.com> wrote:
> On 05/20/2015 01:56 AM, Eric Snow wrote:
>> Makes sense. This does remind me of something I wanted to ask. Would
>> it make sense to leverage ModuleSpec.loader_state? If I recall
>> correctly, we added loader_state with extension modules in mind.
> I don't think we want to go out of our way to support non-module
> objects. Module subclasses should cover any needed functionality, and
> they will support slots.
Sorry I wasn't clear. ModuleSpec.loader_state isn't related to
non-module objects or module subclasses. It's a mechanism by which
finders can pass some loader-specific info to the loader. It could
also be used to maintain some initial module state separately from the
module. As I said, I thought we added loader_state with extension
modules in mind, so I figured I'd ask.
>> Hey, I tried to make something happen over on python-ideas! :) Some
>> folks just don't want to go far enough.
> Yeah, as someone who's trying to get Python3 porting patches to Samba, I
> can tell you some upstreams really, really, really don't like rewriting
> their code.
Sure. I'm not advocating for folks to rewrite their extension
modules. Rather I want the docs to be more active in encouraging the
use of tools like Cython. I think the discussion on python-ideas
could still be resolved favorably. Mostly I had other things to do so
I didn't move things forward. :)
>> Yuck. Is this something we could fix? Is __module__ not set on all functions?
> The module object is not stored on classes, so methods dont' have access
> to it.
Do classes defined in an extension module not have a __module__
attribute (holding the module name)?
> I want a fix for that to be my next PEP :)
Cool! It may be good to have an explicit section in this PEP about
possible follow-up features (e.g. "Out of Scope").
Also, it would be a good idea to have an explicit section in the PEP
about backward-compatibility. (Pretty sure there wasn't one.) This
is an important aspect of every PEP and should be clearly
communicated, even if just to say there is no
backward-incompatibility. Such a section is also a good place to
clearly indicate what extension authors need to do to adapt to the new
More information about the Import-SIG