[Patches] [Patch #101243] Use a compile time mechanism to 'find "import-from" args'

noreply@sourceforge.net noreply@sourceforge.net
Mon, 21 Aug 2000 17:21:49 -0700


Patch #101243 has been updated. 

Project: 
Category: core (C code)
Status: Open
Summary: Use a compile time mechanism to 'find "import-from" args'

Follow-Ups:

Date: 2000-Aug-20 16:57
By: twouters

Comment:
This patch changes the mechanism used to find the 'import-arguments' as passed to __import__ (and used by 'ni' and such dynamic import mechanisms.) The current mechanism looks into the 'future' bytecode stream (from the IMPORT_NAME statement onward) looking for IMPORT_FROM statements. The problem is that this limits the extend in which we can change IMPORT_FROM, and that this is a runtime check for information which was available at compile-time.

Instead, we create a list of import-from arguments, and push it on the stack. The list creation is still done at runtime (it has to be, I think ?) but it's a simple push-constants-on-the-stack-and-BUILD_LIST operation.

The result is that all 'import arguments' (the names imported-from another module) are present not only as normal 'names' in the co_names list, but also as PyString objects in the co_consts list. And that pystone runs a few promille faster on my machine. And that more trickery is allowed in imports, such as those that patch #101234 allows.

-------------------------------------------------------

Date: 2000-Aug-21 20:18
By: tim_one

Comment:
Leaving unassigned for the moment.
I'm all in favor of moving stuff from runtime to compile-time, I just don't have time to look at this now.

OK, not leaving unassigned:  Guido, is there a reason Thomas couldn't build a *tuple* of names at compile-time and stuff that into co_consts?
-------------------------------------------------------

Date: 2000-Aug-21 20:21
By: tim_one

Comment:
Leaving unassigned for the moment.
I'm all in favor of moving stuff from runtime to compile-time, I just don't have time to look at this now.

OK, not leaving unassigned:  Guido, is there a reason Thomas couldn't build a *tuple* of names at compile-time and stuff that into co_consts?
-------------------------------------------------------

-------------------------------------------------------
For more info, visit:

http://sourceforge.net/patch/?func=detailpatch&patch_id=101243&group_id=5470