[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 04:38:01 CET 2009

Brett Cannon writes:
 > On Wed, Feb 4, 2009 at 02:18, Arnaud Delobelle <arnodel at googlemail.com> wrote:
 > > 2009/2/4  <rocky at gnu.org>:
 > >
 > >> There's also the mtime that needs to be ignored mentioned in prior
 > >> posts. And is there a table which converts a magic number version back
 > >> into a string with the Python version number? Thanks.
 > >
 > > You can look at Python/import.c, near the top of the file.
 > The other option to see how all of this works is importlib as found in
 > the py3k branch. That's in pure Python so it's easier to follow.
 > -Brett

Sorry for the delayed response - I finally had a chance to check out the
py3k code and look. 

Perhaps I'm missing something. Although there is some really cool,
well-written and neat Python code there (and some of the private
methods there seem to me like they should public and somewhere else,
perhaps in os or os.path), I don't see a table mapping magic numbers
to a string containing a Python version as you would find when running
"python -V" and that's what was kind of asked for.

As Arnaud mentioned, Python/import.c has this magic-number mapping in
comments near the top of the file. Of course one could take those
comments and turn it into a dictionary, but I was hoping Python had
such a dictionary/function built in already since needs to be
maintained along with changes to the magic number.


More information about the Python-ideas mailing list