byte compiled files and acute neurological disorders

Ken Seehof kens at sightreader.com
Thu Jul 26 15:19:17 EDT 2001


I don't know the details of your situation, but I can offer this suggestion:

Don't use
    from mymodule import *
unless mymodule is completely stable (preferably not yours).

I generally only use that for third party modules that I don't change
because "from ... import" ruins module dependency logic.

Suppose module A imports * from module B.

The problem is that A only gets recompiled if the timestamp on A.py file
is later than A.pyc (otherwise the compiler assumes that A hasn't changed).
Now, suppose B changes.  B.pyc gets updated, but A.pyc does not.

To confuse thing further, if you're running your program from a python
interpreter that doesn't restart on each run, you get an analogous problem.
A change to module B will not affect module A until A is reloaded!  This
is a problem even if you are using "import A" instead of "from A import *",
if your imports are nested two or more levels deep.  The solution to this
is to use reload as needed.  When you release your module, you can
remove the reload.  Of course, reloading won't solve problem describe
in the previous paragraph.

If you really want "from mymodule import *" you can do this sequence:
    import mymodule
    reload(mymodule)
    from mymodule import *

This is kind of wasteful of CPU cycles though.

Time for a PEP if someone can think of a solution.  Maybe the compiler
could store dependency information in the pyc file.  My doctor won't let
me work on this problem any more.

What's really confusing is that these two effects mix together and cause
minor strokes, seizures, and other neurological disorders which also
have symptoms including confusion and disorientation.  It's sometimes
hard to tell hard to which help me problem to tell conforientate it's hard
too hard
help me too hard help discomphoriated aablblblepoouuuughhhh

- Ken Seehooooooaaaauuuugh

----- Original Message -----
From: "Mark Robinson" <m.1.robinson at herts.ac.uk>
Newsgroups: comp.lang.python
To: <python-list at python.org>
Sent: Thursday, July 26, 2001 7:56 AM
Subject: byte compiled files


> can anyone shed some light on the mysterious behaviour of my byte
> compiled files. I am currently working on a python script which analyses
> patterns in a DNA sequence. I have a function which checks a pattern (a
> substring of approx 6 chars) to ensure only valid charactors are
> present. When I first run this program it runs fine, but if I
> immediately rerun the program (i.e using the pre-byte compiled file) it
> finds all patterns non-valid. If I delete the .pyc file between runs
> this problem does not occur. Can anyone explain what is happening here
> to me and how to prevent it?
>
> blobby
>
> --
> http://mail.python.org/mailman/listinfo/python-list





More information about the Python-list mailing list