[Python-ideas] Importing orphaned bytecode files
John Arbash Meinel
john.arbash.meinel at gmail.com
Wed Dec 9 20:34:41 CET 2009
Guido van Rossum wrote:
> On Wed, Dec 9, 2009 at 11:07 AM, Jared Grubb <jared.grubb at gmail.com> wrote:
>> On 8 Dec 2009, at 13:44, Ben Finney wrote:
>> * A new attribute ‘sys.import_orphaned_bytecode’. If set ‘True’, the
>> interpreter follows the current behaviour. If ‘False’, any bytecode
>> file satisfies an import only if it has a corresponding source file
>> (where “corresponding” means “this source file would, if compiled,
>> result in a bytecode file replacing this one”).
>> One problem with a sys flag is that it's a global setting. Suppose a package
>> is distributed with only pyc/pyo files, then the top-level __init__.py might
>> flip the switch such that its sub-files can get imported from the pyc/pyo
>> files. But you wouldnt want that flag to persist beyond that.
> I'm not sure that there are any use cases that require using
> conflicting values of this setting for different packages.
Well, during development of your own codebase, where you would like to
not import stale .pyc files, but it depends on a 3rd-party library where
they only ship you .pyc files.
Now if the flag was somehow "for all modules under this namespace" that
would easily handle it.
Or just living with "if you want to use private 3rd-party libs, then you
don't get this support for your own development".
(I don't currently do this, but it certainly is *a* use case.)
More information about the Python-ideas