473,396 Members | 1,713 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Out-dated compiled modules (*.pyc)?

Hi folks,

how can I prevent Python from adding or using *.pyc files if executing a
Python module? I have the strong feeling that the interpreter uses
out-dated pyc file instead more recent py files. At least I already had
some cases where application behaviour changed only by removing the
*.pyc files from the app directory, and in all these cases I interpreted
the difference in code changes I already saved in py files but which had
no effect before removing their pyc versions. I'm not very happy on
deleting pyc files before each execution.

I know there is an -o option for turning on optimization (pyo). In doc I
could not found a hint to an option to turn off pyc compilation -- or at
least forcing the interpreter to use py files only.

I'm working with Python 2.4.2 on WinXP, Eclipse 3.2 with PyDev 1.2.2

Thanks for your help!

Anastasios
Aug 26 '06 #1
2 2011
Anastasios Hatzis wrote:
Hi folks,

how can I prevent Python from adding or using *.pyc files if executing a
Python module? I have the strong feeling that the interpreter uses
out-dated pyc file instead more recent py files. At least I already had
some cases where application behaviour changed only by removing the
*.pyc files from the app directory, and in all these cases I interpreted
the difference in code changes I already saved in py files but which had
no effect before removing their pyc versions. I'm not very happy on
deleting pyc files before each execution.

I know there is an -o option for turning on optimization (pyo). In doc I
could not found a hint to an option to turn off pyc compilation -- or at
least forcing the interpreter to use py files only.

I'm working with Python 2.4.2 on WinXP, Eclipse 3.2 with PyDev 1.2.2

Thanks for your help!

Anastasios
The interpeter will always use the newer .py files in preference to
older.pyc files, overwriting the .pyc files with newer versions.

However, if your interpreter is re-importing a module without either
re-starting (the interpreter) or reloading()'ing the module, it will
use the loaded version in the sys.modules cache. This used to happen
in IDLE before it was given the ability to run the interpreter in a
separate subprocess. Now it automatically restarts the interpreter. I
don't know whether Eclipse has this problem but it might.

There are at least three ways of dealing with this: 1) Restart the
interpreter (manually or through some IDE option), 2) call reload() on
your modules, or 3) del the modules from sys.modules before
re-importing them.

Peace,
~Simon

Aug 26 '06 #2
On Sat, 2006-08-26 at 18:54 +0000, Dennis Lee Bieber wrote:
Normally, Python compares the date stamps of the files (and maybe
some internal magic values) and only rebuilds the .pyc if the .py is
newer.
Perhaps the OP should check both the system date on his PC and the
timestamp on the pyc files in question.

Cliff
Aug 26 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Tony C | last post by:
After using Python for just over a year now, I've noticed something for the first time. I've written an application in one .PY file, and a class definition in another.PY file. (The application...
5
by: LutherRevisited | last post by:
This may be a dumb question, but are there any practical advantages of compiling a python application to *.pyo, or *.pyc? I haven't noticed any difference in the performance of text *.py or a...
5
by: Blair Hall | last post by:
I have a requirement to prevent 'accidental' tampering with some software written in Python. If I ensure that all of the modules concerned are compiled into .pyc's, and remove the .py's to another...
4
by: Tomasz Lisowski | last post by:
Hi, We are distributing our Python application as the short main script (.py file) and a set of modules compiled to the .pyc files. So far, we have always treated .pyc files as portable between...
2
by: James Buchanan | last post by:
Hi group, I'm preparing Python 2.4.2 for the upcoming Minix 3.x release, and I have problems with make. configure runs fine and creates the makefile, but right at the end ends with an error...
12
by: Byte | last post by:
Pretty much self explanatry, where are Python modules stored in Linux? (i.e. in /usr/bin/local, or where?)
7
by: venkatbo | last post by:
Hi all, We've managed to cross-compile (from i686 targeting ppc) python (2.4.2) binaries and extension modules. However we cannot figure out how to cross-compile the .py (of distribution)...
6
by: chatpratap | last post by:
I wanted to see the python compiled files (.pyc) when i execute python .py files. help me how would i get .pyc files generated.
24
by: Mark | last post by:
Hi, I'm new to python and looking for a better idiom to use for the manner I have been organising my python scripts. I've googled all over the place about this but found absolutely nothing. I'm...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.