[Python-ideas] Add a cryptographic hash (e.g SHA1) of source toPython Compiled objects?

rocky at gnu.org rocky at gnu.org
Fri Feb 6 21:10:34 CET 2009

 > I still don't see the benefit of knowing what version of Python a
 > magic number matches to. So I know some bytecode was compiled by
 > Python 2.5 while I am running Python 2.6. 

Yep. Not uncommon for me to have several versions of Python
available. It so happens that the computer where this email is being
sent has at least 9 versions, possibly more because I didn't check if
python.new and python.old are one those other 9. (I don't maintain
this box, but pay someone else to; clearly this is a pathological
case, but it's kind of interesting to me that there are at more than 9
versions installed and I did not contrive this case.)

 > What benefit do I derive
 > from knowing that compared to just knowing that it was not compiled by
 > Python 2.6? I mean are you ultimately planning on launching a
 > different interpreter based on what generated the bytecode?

If there's a mismatch in the first place, it means there's confusion
on someone's part. Don't you want to foster development of programs
that try to minimize confusion? Subsidiary effects when support of
magic to version string are not readily available in situations where
it would be helpful is possibly back and forth dialog in bug reports
one is asking what telling folks how to get the version number
(because it's not in the error message because its not readily
available by a programmer). Never underestimate the level of users,
especially if you are working on something like a debugger.

If we hope that someone's going to know about and read that comment in
the C file turn it into a dictionary and maintain it anytime the magic
number gets updated, it's probably not going to happen often.

Again, although I see specific uses in a debugger this really an issue
regarding code tools or programs that deal with Python code. I know
there's a disassembler, but you mean there isn't a dump tool which
shows all of the information inside a compiled object including a
disassembly, Python version the program was compiled with, mtime in
human readable format, and whatnot?

More information about the Python-ideas mailing list