
On Wed, Dec 9, 2009 at 11:07 AM, Jared Grubb <jared.grubb@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.
Another idea is to use a new file extension, which isnt the best solution, but allows the creator to explicitly set what behavior they intended for their files: * if a foo.py file exists, then use the existing foo.pyc/pyo as is done today * if a foo.py file does not exist, but a foo.pyxxx exists, use it (but file.pyc/pyo is never used, unlike today) (pyxxx is a placeholder for whatever would be a reasonable name)
It's a much bigger change, but using a different extension would probably remove the need for a flag. It would also help with some tools that hide .pyc/.pyo files from view (e.g. the typical .svnignore). -- --Guido van Rossum (python.org/~guido)