some uglyness in Python imho

Jay Krell jay.krell at cornell.edu
Sun Sep 10 04:10:52 CEST 2000


I hadn't considered the difficulty of maintenance. Darn.

>Since most development is done on Unix...

Something to consider when most development moves to Windows. :)

Right about Tcl. They used to run a simple (but correct) tool over the .objs
to generate the .def. I think they're fully/only
__declspec(dllimport/dllexport) now. I don't know why.

> ...besides, if Microsoft didn't want us to use this, they
> shouldn't have added the declspec directive to the compiler
> in the first place ;-)

__declspec(dllimport) is a slight optimization, which is probably a big
reason it exists. It saves one instruction per imported function call on
x86, and some scheduling freedom, which the compiler actually takes
advantage of. Without __declspec(dllimport), calls to imported functions are
calls to a one instruction function that jumps through the (patched at
runtime)) function pointer. With __declspec(dllimport), calls to imported
functions are call through the function pointer, and sometimes the optimizer
preloads the contents of the function pointer into a register and later
jumps through it.

__declspec(dllimport) on data is "impossible" without __declspec(dllimport),
you have to use functions instead.

I still doubt it's worth it..

And just fyi, sometimes both the __declspecs and a .def file are used, like
to get the optimization and to export by ordinal.

 - Jay





More information about the Python-list mailing list