473,326 Members | 2,133 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,326 software developers and data experts.

saving pre-compiled scripts

Hi,

I'm working on an application that reads python scripts from XML
elements and compiles them during my app's startup process using. The
application then runs the resulting compiled PyCodeObjects using
PyEval_EvalCode as they are needed.

Now I'm wondering if its possible to pre-compile the scripts and save
the PyCodeObjects in a binary file (or in CDATA in an XML element) and
have them ready to run when the application starts up.

My only constraint is that I need to be able to load the scripts from
memory (which is why using Py_CompileString has worked well for me).

Is there any way I can get the size of a PyCodeObject so that I could
save it to a binary file? If I did that would it run correctly if I
reloaded it and tried to Eval it? Can I load a pyc file from memory
somehow?

Any guidance would be greatly appreciated.

Thanks,
Derek

Jul 19 '05 #1
2 1429
Another thing which may be important to note re: my constraints is that
each script is essentially being run as a function.

In fact, every script element I parse in XML gets wrapped in a function
def before I send it to Py_CompileString.

I then PyEval the result of that function, and then run
Py_CompileString again, passing only the automatically generated
function call.

The result of the second Py_CompileString is what I pass to
PyEval_EvalCode whenever my app needs to run that script (function).

Jul 19 '05 #2
I probably should have also mentioned that my application is written in
C++ and using the Python/C API.

Jul 19 '05 #3

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

Similar topics

3
by: Vikram | last post by:
Hi, Given below is my task. An user can open the xls file from my website (loaded on the top frame). After filling the Excel, he can click a send button at the bottom frame. By clicking the...
45
by: Stephen Poley | last post by:
People in these groups, and on web-pages, not infrequently suggest that it is worthwhile cutting down on white-space and comments in HTML and CSS in order to reduce loading times. I and others have...
26
by: geolev | last post by:
I'm trying to understand the effects of the Daylight Saving Time rule changes for 2007 in the US. Can anyone tell me how Javascript knows when to apply Daylight Saving Time in the following script?...
2
by: Jim | last post by:
Hi All, I would appreciate a pointer on this problem, if you please. I am writing a 'tell a friend' page for my www site. Essentially, the user opens the page, fills out a form, click submit,...
6
by: kpmassey | last post by:
I am trying to use wget to retrieve web pages like this: http://www.michigan-football.com/s/2006/cascades.htm Visit it and view source to see the obfuscated javascript. Is there any tool to...
10
by: =?Utf-8?B?VGhyb3dtZSBBIEZyaWdnaW5ib25l?= | last post by:
I apologize if this is in the wrong discussion group. I have a C++ form (VS2003) that includes a couple text boxes and a slider bar. Moving the slider bar changes a picture that is displayed and...
5
by: slan | last post by:
I'm learning Java for about 2-3 weeks and I'm stuck and I'm not sure if I have the car in front of my horses or no: All the programs I learned from the book (yep that one for dummies) is about...
27
by: RobG | last post by:
I was investigating a function to determine whether daylight saving was being observed on a particular date (given the platform's regional settings) and came across a suggestion at merlyn.com to...
6
by: Eddie | last post by:
Hi all, I am displaying a number of reports, and giving the users an option to display them on the web or download them to Excel. If they want the Excel file, I just use the PHP header command...
2
by: houghi | last post by:
I am trying to do two things at a time. I want to give the user the opportunity to save a file and at the same time see new information on the screen. I can do it seperately, but not together....
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

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.