Directly importing a .pyc file?
Richard Harvey
tririch at connect.net
Wed Sep 6 15:03:23 EDT 2000
I've successfully figured out how to parse, compile, and import in a module
through the C API, using the following pseudocode:
node = PyParser_SimpleParseFile(f, moduleName, 256);
code = PyNode_Compile(node, moduleName);
module = PyImport_ImportModule(moduleName);
At the point PyImport_ImportModule is called, Python writes out the .pyc
file for my script. My question is this: if I detect that a .pyc file
exists, is there a way to directly import it without repeating the compile
step? I want to know this to determine if I can successfully distribute
precompiled scripts without requiring the original .py file.
Thanks,
Rich
More information about the Python-list
mailing list