On my Debian GNU/Linux system I have Python 2.3 installed in
/usr/lib/python2.3/ where most Python system files like
/usr/lib/python2.3/gzip.py
/usr/lib/python2.3/gzip.pyc
/usr/lib/python2.3/gzip.pyo
live, besides of course /usr/bin/python2.3
I noticed that all those files come in three "flavours":
*.py *.pyc *.pyo
Is it possible that only one "flavour" of these files is needed, and I can
delete the remaining two, any my Python installation will still work?
The whole /usr/lib/python2.3/ directory takes up over 15 MB, deleting
two "flavours" would save about 10 MB on my system, and that would help
me much as I am trying to fit my system on a 256 MB SD card, to make it
quiet (hard disks are noisy).
Can I just do
cd /usr/lib/python2.3/ && rm -rf *.py && rm -rf *.pyc
for example, and everything will still work as before?
--
Miernik _________________________ xmpp:mi*****@amessage.info
___________________/_______________________/ mailto:mi*****@ffii.org
Protect Europe from a legal disaster. Petition against software patents http://www.noepatents.org/index_html?LANG=en 6 2808
Miernik wrote: On my Debian GNU/Linux system I have Python 2.3 installed in /usr/lib/python2.3/ where most Python system files like
/usr/lib/python2.3/gzip.py /usr/lib/python2.3/gzip.pyc /usr/lib/python2.3/gzip.pyo
live, besides of course /usr/bin/python2.3
I noticed that all those files come in three "flavours": *.py *.pyc *.pyo
Is it possible that only one "flavour" of these files is needed, and I can delete the remaining two, any my Python installation will still work?
The whole /usr/lib/python2.3/ directory takes up over 15 MB, deleting two "flavours" would save about 10 MB on my system, and that would help me much as I am trying to fit my system on a 256 MB SD card, to make it quiet (hard disks are noisy).
Can I just do cd /usr/lib/python2.3/ && rm -rf *.py && rm -rf *.pyc for example, and everything will still work as before?
You can delete any two of the three and you shouldn't run into any
problems. However, the .py files are the source code and .pyc and .pyo
are compiled Python files. The .pyc and .pyo files will load faster
because they are compiled. Also, if you keep the .py files and then
execute them, .pyc files will be generated. In short, I would keep the
..pyc files and delete the others.
--
--------------------------
Lucas Raab
lvraab"@"earthlink.net
dotpyFE"@"gmail.com
AIM: Phoenix11890
MSN: dotpyfe "@" gmail.com
IRC: lvraab
ICQ: 324767918
Yahoo: Phoenix11890
Miernik a écrit : On my Debian GNU/Linux system I have Python 2.3 installed in
[...] I noticed that all those files come in three "flavours": *.py *.pyc *.pyo
Is it possible that only one "flavour" of these files is needed, and I can delete the remaining two, any my Python installation will still work?
Well, I would greatly discourage that ! First, if you erase the *.py,
you won't be able to get detailed information on the traceback (like
actual code causing throwing the exception) as only the filename/line is
kept in the .pyc or .pyo. Then, if you erase the .pyo that means you
don't want to use the optimized version of the modules (why not ... but
it will be at the cost of performances). At last, if you keep only the
..pyo you won't be able to run programs without the optimization.
So let's summarize :
1 - you keep only .py files: everything will work but Python will have
to recompile the modules everytime it's used first
2 - you keep only .pyc files: two problems: first you won't be able to
launch Python with the "-O" option (i.e. optimize) because it will look
for .py or .pyo files, then if any exception is thrown in one of the
modules, you won't be able to use the very good pdb module with code
information and all.
3 - you keep only .pyo files: similar to keeping only the .pyc files
but you won't be able to launch Python without the "-O" ! The whole /usr/lib/python2.3/ directory takes up over 15 MB, deleting two "flavours" would save about 10 MB on my system, and that would help me much as I am trying to fit my system on a 256 MB SD card, to make it quiet (hard disks are noisy).
Can I just do cd /usr/lib/python2.3/ && rm -rf *.py && rm -rf *.pyc for example, and everything will still work as before?
Well, if you don't care about performances, the best to do is (using zsh
;) ):
cd /usr/lib/python2.3 && rm -f **/*.py{o,c}
Pierre
Lucas Raab a écrit : Miernik wrote:
[...] You can delete any two of the three and you shouldn't run into any problems. However, the .py files are the source code and .pyc and .pyo are compiled Python files. The .pyc and .pyo files will load faster because they are compiled. Also, if you keep the .py files and then execute them, .pyc files will be generated. In short, I would keep the .pyc files and delete the others.
As I said in my other post, if you ever run python using the "-O" and
have neither the .py nor the .pyo file, it won't load the module (even
if the .pyc is present ...)
Pierre
Miernik wrote: On my Debian GNU/Linux system I have Python 2.3 installed in /usr/lib/python2.3/ where most Python system files like
/usr/lib/python2.3/gzip.py /usr/lib/python2.3/gzip.pyc /usr/lib/python2.3/gzip.pyo
live, besides of course /usr/bin/python2.3
I noticed that all those files come in three "flavours": *.py *.pyc *.pyo
Is it possible that only one "flavour" of these files is needed, and I can delete the remaining two, any my Python installation will still work?
The whole /usr/lib/python2.3/ directory takes up over 15 MB, deleting two "flavours" would save about 10 MB on my system, and that would help me much as I am trying to fit my system on a 256 MB SD card, to make it quiet (hard disks are noisy).
Can I just do cd /usr/lib/python2.3/ && rm -rf *.py && rm -rf *.pyc for example, and everything will still work as before?
You can put them all in a .zip (repeating the structure), named
python23.zip, and put that zip file where the search path looks
for it. Having built python23.zip, you can delete all the
..py, .pyc, .pyo files you put in the zip. Compress them
using "DEFLATE", since Python's zipfile module doesn't do
BZIP2 compression (yet).
--Scott David Daniels Sc***********@Acm.Org
Miernik wrote: I noticed that all those files come in three "flavours": *.py *.pyc *.pyo
Is it possible that only one "flavour" of these files is needed, and I can delete the remaining two, any my Python installation will still work?
If you remove all *.pyc and *.pyo, they will be regenerated as needed.
If your code only uses a small fraction of the standard library, you
will save quite some space here. The only reason they are generated on
installation is to save some runtime on first use of a module, and
perhaps aviod the surprise of an installation that continues to grow
after a completed installation...
I'm not sure about this, but if you have plenty of RAM (you will
trade HD noise for fan noise I guess) you might get the *.py[co] files
to stay on a RAM disk. (If nothing else works, I guess you could have
your system mirror your entire Python directory structure to RAM disk
at boot time.) Then you should have a Python system which will get
really fast once most modules have been recompiled--until you reboot...
Magnus Lycka wrote: If you remove all *.pyc and *.pyo, they will be regenerated as needed. If your code only uses a small fraction of the standard library, you will save quite some space here. The only reason they are generated on installation is to save some runtime on first use of a module, and perhaps aviod the surprise of an installation that continues to grow after a completed installation...
Another reason is to allow efficient access to python for users who
do not have permission to create files (the .pyc and .pyo files) in
Python's library directories.
--Scott David Daniels Sc***********@Acm.Org This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Jakub Moscicki |
last post by:
Hello,
A small problem: I get a signal during a system call (from xmlrpclib ->
httplib) and an exception "IOError: Interrupted system call" is
raised (this is system dependant, on other machine...
|
by: tudor |
last post by:
hello!
I had python 2.2.1 so I upgraded to python 2.3.2, but all my
applications using python (rh8) give errors now. I installed from src.rpm
Traceback (most recent call last):
File...
|
by: Adil Hasan |
last post by:
Hello,
I'm having problems trying to use ZSI to connect to a https url.
I give the command and I get prompted for my X509 cert pass-phrase, but
the program dies with an openssl error.
Here's my...
|
by: km |
last post by:
Hi all,
is there a debian binary of python2.4 ?
tia,
KM
|
by: Tim N. van der Leeuw |
last post by:
Hi,
When trying to use win32com functionality with Python2.4, the
interpreter often crashes!
I don't know if it's a known problem already that will be fixed in an
upcoming Python2.4.1...
|
by: Wolfgang |
last post by:
I have a problem with linking my CPP Code under a irix6 machine (sgi,
UNIX). In my CPP code I use some Functions which are written in
Python. So its a kind of CPP wrapper for my Python functions In...
|
by: venkatbo |
last post by:
Hi all,
I have python2.4 running on ppc-linux 2.6.17. I'm attempting to get
a TurboGears 0.9a9 (using CherryPy 2.2.1) based app running on
it.
During the TG-app startup sequence, it reaches...
|
by: Christopher Taylor |
last post by:
RHEL comes with Python2.3 installed. A program I need to install
requires Python2.4
So I got Python2.4 from source and compiled it up. I configured it
with --prefix=/usr --exec-prefix=/usr...
|
by: samn |
last post by:
i compiled and installed the release version of python 2.5 for linux to
a directory accessible to 2 computers, configured with
--prefix=/usr/arch (which is accessible to both machines). the...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
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...
|
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
|
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...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
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...
|
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,...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
| |