473,396 Members | 2,004 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.

pyc files located elsewhere?

Greetings.

On Python 2.3.3, is there any way to have the .pyc files created
elsewhere than in the same dir as the source files?

I have an application that consists of about 30 source files including
a few packages.

I would like it if my .pyc files could be in a subdir of the app root
if possible. I would have to make sure that the subdir structure
underneath matched the structure of the app itself.

I would also consider having each package directory have its own PYC
directory and the compiled files could go in there even.

So, can I feed a prefix to the system that checks for and creates .pyc
files somehow? My review of the Pydocs for related compilation issues
didn't seem to turn up an answer.

Thanks.
--
-------------------------------------------------------------------------------
Jerry Sievers 305 854-3001 (home) WWW ECommerce Consultant
305 321-1144 (mobile http://www.JerrySievers.com/
Jul 18 '05 #1
5 2058
> I would like it if my .pyc files could be in a subdir of the app root
if possible. I would have to make sure that the subdir structure
underneath matched the structure of the app itself.

I would also consider having each package directory have its own PYC
directory and the compiled files could go in there even.

So, can I feed a prefix to the system that checks for and creates .pyc
files somehow? My review of the Pydocs for related compilation issues
didn't seem to turn up an answer.


I don't know if it is possible to automatically write to a different
path, but I /think/ one can /turn off/ writing .pyc files, but it would
necessarily make running the script slower (you don't get cached .pyc
files, so every import requires a py->ptc compilation).

- Josiah

Jul 18 '05 #2
Josiah Carlson wrote:
I don't know if it is possible to automatically write to a different
path, but I /think/ one can /turn off/ writing .pyc files, but it would
necessarily make running the script slower (you don't get cached .pyc
files, so every import requires a py->ptc compilation).


Just to clarify (and I don't know turning that feature off is really
possible, so maybe it's a useless point), but not *every* import will
require the compilation. The first import of any given module will
require the compilation, each time you run the application. If a
module is imported fifty times, all but the first just retrieve
the module from sys.modules, same as normal.

(Is what you describe really possible? I've never heard of it.)

-Peter
Jul 18 '05 #3
>
(Is what you describe really possible? I've never heard of it.)


It seems that its at least not doable using commandline args. But I have to
admit that I love to see that feature - so far, pyc didn't by me anything
except trouble to clear my src-dirs when using a version control system to
prevent them beeing checked in. I'm very well aware of .cvsignore and the
like - but I'd prefer to turn off the compilation.

--
Regards,

Diez B. Roggisch
Jul 18 '05 #4
> Josiah Carlson wrote:
I don't know if it is possible to automatically write to a different
path, but I /think/ one can /turn off/ writing .pyc files, but it would
necessarily make running the script slower (you don't get cached .pyc
files, so every import requires a py->pyc compilation).
Just to clarify (and I don't know turning that feature off is really
possible, so maybe it's a useless point), but not *every* import will
require the compilation. The first import of any given module will
require the compilation, each time you run the application. If a
module is imported fifty times, all but the first just retrieve
the module from sys.modules, same as normal.


Right, but if you have 50 modules that are imported (50 unique module
files), then you still have to compile those 50 every time. The speed
hit really depends on the size of the application, and how often
restarts occur.

(Is what you describe really possible? I've never heard of it.)


I know that importing from a non-writable location disables writing of
pyc files (zip imports, etc.), and I am fairly certain it can be done
with an import hook, though never having need for it, I've never tried.

- Josiah

Jul 18 '05 #5
(Is what you describe really possible? I've never heard of it.)


Josiah> I know that importing from a non-writable location disables
Josiah> writing of pyc files (zip imports, etc.), and I am fairly
Josiah> certain it can be done with an import hook, though never having
Josiah> need for it, I've never tried.

Please have a look at PEP 304. Feedback welcome.

Skip
Jul 18 '05 #6

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

Similar topics

6
by: Sylvain Thenault | last post by:
Hi there ! I've some questions regarding pth files (which btw are undocumented in the python reference, is this intentional ?) I thought that I could use a .pth file to be able to import zope...
1
by: Victor Spång Arthursson | last post by:
Well, bought a new disk to my Powerbook yesterday and reinstalled Mac OS X. I'm in the middle of restoring everything now, and need to know where the database files where located. I thougt...
1
by: grzybek | last post by:
Hi, I have question about techniques of using files in SQL Server in Web Application. Assuming that I send files from my Web App ( client ) to server and located these files on hard disk ( on...
6
by: Peter Row | last post by:
Hi, Can someone give me a set of steps for an ASP.NET project (well actually its just a VB.NET class DLL that implements HttpHandler) that will work when moved to another developers machine? ...
18
by: Joe Lester | last post by:
This thread was renamed. It used to be: "shared_buffers Question". The old thread kind of died out. I'm hoping to get some more direction by rephrasing the problem, along with some extra...
3
by: Steve Teeples | last post by:
I have a simple application built with several DLLs that access XML files for information. My local setup works just fine. As defined in my Install folder, the files are copied to the...
4
by: AA | last post by:
Hi, I am having to vb files. One is located under C:/VB/main and the other is under C:/VB/class. File under main looks like: <code> Module Module1 Sub Main() Dim test As New Test1
6
by: 2112 | last post by:
I'm compiling a dll that imports msado15.dll. When I'm using Windows in English, the msado15.dll is located at <drive>:\Program Files\Common Files\System\ADO\msado15.dll". When using Windows in...
6
by: Homer J. Simpson | last post by:
Hi all, I have enough experience with HTML/classic ASP to get by, and I'm trying to learn ASP.NET. Traditionally, I've taken the habit of breaking out extra-long CSS files into multiple,...
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: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
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...
0
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,...
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
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,...

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.