".pyc" file support
Closed this issue · 1 comments
It is highly possible, that a package/module contains the .pyc
(py
thon c
ompiled) files in the HTTP/S repo/directory. This could happen, if the package/module has been run/imported, at least once, locally.
Yet the httpimport
module, as is, looks only for .py
files.
There can be a modification/flag/optional argument, that enables the Importer
class to look for .pyc
files and strip their contents to make them executable. This can be done, as these files include the output of compile()
Python function, and the output of compile()
can be used with exec
function/statement.
This will probably enhance loading time!
Commit 15647a3 contains the httpimport.NON_SOURCE
variable. It is False
by default.
If toggled, the HttpImporter
class will look for the .pyc
version of each module, falling back to .py
if not found.
As .pyc
file header specification changed in Python3 (from 8 bytes to 12 bytes), httpimport
uses the ValueError
to determine if the .pyc
got properly deserialized (unmarshal
ed), for the version of Python running. Falls back to .py
in any case of incompatibility.