[Python-Dev] Should there be a source-code checksum in module objects?

Brett Cannon brett at python.org
Mon Feb 2 19:25:04 CET 2009


On Mon, Feb 2, 2009 at 00:52, Rocky Bernstein <rocky at gnu.org> wrote:
> As I've mentioned, I've been re-examining from ground up the whole
> state of affairs in writing a debugger.
>
> One of the challenges of a debugger or any source-code analysis tool
> is verifying that the source-code that the tool is reporting on
> corresponds to the compiled object under execution. (For debuggers,
> this problem becomes more likely to occur when you are debugging on a
> computer that isn't the same as the computer where the code is
> running.)
>
> Is there a checksum of the source text computed and stored in
> compilation?

No, only the bytecode version used, the mtime of the source the
bytecode is derived from, and the bytecode itself.

> If not, should there be one?

If you are planning to read this directly from the .pyc file then it
is not needed as the mtime timestamp in the .pyc should in general be
enough to detect changes to the source.

-Brett


More information about the Python-Dev mailing list