473,624 Members | 2,069 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

can I delete one of *.py *.pyc *.pyo in /usr/lib/python2.3 ?

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*****@am essage.info
_______________ ____/_______________ ________/ mailto:mi*****@ ffii.org
Protect Europe from a legal disaster. Petition against software patents
http://www.noepatents.org/index_html?LANG=en

Aug 20 '05 #1
6 2818
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"@"earthl ink.net
dotpyFE"@"gmail .com
AIM: Phoenix11890
MSN: dotpyfe "@" gmail.com
IRC: lvraab
ICQ: 324767918
Yahoo: Phoenix11890
Aug 20 '05 #2
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
Aug 20 '05 #3
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
Aug 20 '05 #4
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***********@A cm.Org
Aug 20 '05 #5
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...
Aug 22 '05 #6
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***********@A cm.Org
Aug 22 '05 #7

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

Similar topics

2
4574
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 it does not raise this exception). I have my own signal handler so I want to simply ignore this exception if it occures. But for a reason mysterious to me I cannot catch this exception in the main's program try block. Anybody knows what's...
4
1812
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 "/usr/sbin/redhat-switch-printer", line 84, in ? main() File "/usr/sbin/redhat-switch-printer", line 68, in main from switchprinter_gui import mainDialog File "/usr/share/redhat-switch-printer/switchprinter_gui.py", line
3
3077
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 code: from ZSI import * u='' n='https://shahzad.fnal.gov/edg-voms-admin/uscms/services/VOMSAdmin'
1
1930
by: km | last post by:
Hi all, is there a debian binary of python2.4 ? tia, KM
1
1622
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 version. Basically, the problem is: makepy.py generates a (large, nearly 2mb) Python file for use with COM
0
1711
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 my Python Code I use threads to communicate over the network and stuff like this. Compilation and linking are working very well under Windows and Linux with the same code. Under the sgi, UNIX machine some errors occur and I don't no why....
2
1647
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 the point where it imports cherrypy, which eventually causes py2.4's system file, compiler/transformer.py, to import a module by name, symbol. Unable to find it, python quits...
15
5544
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 and --enable-unicode=ucs4 . I then make'd it and then make altinstall so that it didn't overwrite the /usr/bin/Python link to /usr/bin/Python2.3 . Well, for some reason, the arch dependent files did NOT get placed properly in...
6
22467
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 installation went fine and when i run python on one machine i can do from hashlib import * without a problem. on the other machine i get the following error: Traceback (most recent call last): File "<stdin>", line 1, in <module> File...
0
8238
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8174
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8680
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8624
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8478
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7164
agi2029
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
4082
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
1786
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1485
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.