tkinter + stubs

Robin Becker robin at jessikat.demon.co.uk
Fri Feb 18 08:41:30 EST 2000


In article <Dkbr4.4048$dT4.209035776 at newsb.telia.net>, Fredrik Lundh
<effbot at telia.com> writes
>Robin Becker <robin at jessikat.demon.co.uk> wrote:
>> having just had to recompile _tkinter for the third time in the last
>> year I would like to make a plea to Guido to allow export of the dynamic
>> load code in the future python16.dll.
>>
>> My reasoning is this; if stubs are ever to be used with _tkinter the
>> steps to be carried out are
>>
>> determine suitable tcl/tk dynamic libraries.
>> find and call Tcl_CreateInterp () to get an initial interpreter
>> find and call Tcl_InitStubs(interp,version,0)
>> find and call Tk_InitStubs(interp,version,0)
>>
>> to do this easily would mean duplicating all the dynamic loading code.
>> However, if we could avoid always using the "init" prefix then we get
>> the dynamic load almost for free if the entry points are exported.
>
>can you explain what "stubs" are, for an ordinary python
>mortal (or point to an explanation)?
>
>last time I checked, it looked like a home-brewn dynamic
>linking scheme (do it all by hand, instead of using the run-
>time linker?)...

To allow tcl & friends to import extensions without forcing the
extensions to be explicitly linked with a specific tcl/tk dynamic
library the tcl folks produced a method called stub loading. basically
the extension calls all the tcl/tk entry points indirectly.

Normally tcl calls a newly loaded extension with a pointer to the
interpreter as argument. The extension can fill in the indirection
pointers using the statically loaded function Tcl_InitStubs.

Thus by taking the hit of a fixed size indirection table and the fillin
routine the extension becomes relatively independent of the tcl that
calls it; the indirection cost is relatively small for the kind of
things that tcl does.

The _tkinter case is slightly different in that _tkinter embeds Tcl/Tk,
but we can get round that if we dynamically load Tcl, Tk ourselves and
then grab the first interpreter for filling in the Tcl/Tk stub
indirections. We would then have a _tkinter that would not need to be
recompiled for 8.3.1 .... 8.4  etc.

Since _tkinter already has a .py stage we could put the names of
libraries to be used into source to be passed into an initialise
function and thus avoid a potentially hazardous library search.

Tcl/Tk appears to have a faster release schedule than python so this
could be desirable. An additional benefit is that a dynamic loader
module could leverage off the exposed pythonic routines.
-- 
Robin Becker



More information about the Python-list mailing list