[Python-ideas] Importing orphaned bytecode files

Eric Smith eric at trueblade.com
Wed Dec 9 07:18:45 CET 2009

Sorry for top posting. My phone makes me!

You're right: I misread. Sorry about that. 

"Ben Finney" <ben+python at benfinney.id.au> wrote:

>Eric Smith <eric at trueblade.com> writes:
>> Ben Finney wrote:
>> > I suggest:
>> >
>> > * 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”).
>> I agree with this in principle
>> but I don't see how you're going to implement it. In order to actually
>> check this condition, aren't you going to have to compile the source
>> code anyway? If so, just skip the bytecode file. Although I guess you
>> could store a hash of the source in the compiled file, or other
>> similar optimizations.
>You seem to be seeing something I was careful not to write. The check
>   this source file would, if compiled, result in a bytecode file
>   replacing this one
>Nowhere there is there anything about the resulting bytecode files being
>equivalent. I'm limiting the check only to whether the resulting
>bytecode file would *replace* the existing bytecode file.
>This doesn't require knowing anything at all about the contents of the
>current bytecode file; indeed, my intention was to phrase it so that
>it's checked before bothering to open the existing bytecode file.
>Is there a better term for this? I'm not well-versed enough in the
>Python import internals to know.
> \       “Philosophy is questions that may never be answered. Religion |
>  `\              is answers that may never be questioned.” —anonymous |
>_o__)                                                                  |
>Ben Finney
>Python-ideas mailing list
>Python-ideas at python.org

More information about the Python-ideas mailing list