Creating a "package" using C extensions?

Courageous jkraska at san.rr.com
Sun Dec 9 12:09:38 EST 2001


>> I can see that if I just used a normal __init__.py and
>> then pointed it to C extension dlls, this would probably
>> work.
>> 
>> Is this the approved way of doing this?
>
>Yes.

>You could probably hack something up by butchering the 
>module object in some way, but the import code assumes that
>extension modules are just plain modules, not packages.

This is liveable, but somewhat painful for me. Let me tell
you why. I am currently translating the back end of a system
originally written in Python to a hybridized C++/Python
implementation with a C++ core. The heart of the system has
a very high invocation frequency, so it makes sense to put
that into C++. However, I need to make the prior interface
to the Python programmer the same as it was before. So what
I am doing is, for every module in the prior package, creating
a C++ equivalent.

That's a lot of .dlls, if you know what I mean.

Perhaps I'll break down and write a makefile. Doing a couple
dozen .dlls in VC 6.0 is a bit of a pain.

It's too bad there's not a way to create a package-level .dll
which responds to Python in such a way as to offer up its
internal modules, but all from within a single .dll. That would
be cool.

C//




More information about the Python-list mailing list