Re: importing pyc from memory?

2005-07-05 Thread Bengt Richter
On Mon, 4 Jul 2005 13:01:06 -0500, Jeff Epler <[EMAIL PROTECTED]> wrote: > >--s2ZSL+KKDSLx8OML >Content-Type: text/plain; charset=us-ascii >Content-Disposition: inline > >This stupid code works for modules, but not for packages. It probably has >bugs. > > >import marshal, types > >class StringIm

Re: importing pyc from memory?

2005-07-04 Thread Derek van Vliet
I do have to do everything you describe here in the current implementation of my system. I realize that importing a pyc file and compiling a string results in two different things. This is okay though as I'm fairly sure this will still suit my needs. As I said, the file format I plan to store thes

Re: importing pyc from memory?

2005-07-04 Thread Sybren Stuvel
Derek van Vliet enlightened us with: > Up to now, I've had all my python scripts defined in XML elements, > which were compiled when my program started up using > Py_CompileString. This has worked great, but I'm finding that most > of the time my app uses to start up is spent in that > Py_CompileS

Re: importing pyc from memory?

2005-07-04 Thread Bengt Richter
On Mon, 04 Jul 2005 19:25:13 +0200, Thomas Heller <[EMAIL PROTECTED]> wrote: >"Derek van Vliet" <[EMAIL PROTECTED]> writes: > >> The second method you describe sounds like it is along the lines of >> what I need to do. Is there a way to do this using the Python/C API? >> >> For instance, if I have

Re: importing pyc from memory?

2005-07-04 Thread Jeff Epler
This stupid code works for modules, but not for packages. It probably has bugs. import marshal, types class StringImporter: def __init__(self, old_import, modules): self._import = old_import self._modules = modules def __call__(self, name, *args): module = self.

Re: importing pyc from memory?

2005-07-04 Thread Thomas Heller
"Derek van Vliet" <[EMAIL PROTECTED]> writes: > The second method you describe sounds like it is along the lines of > what I need to do. Is there a way to do this using the Python/C API? > > For instance, if I have the contents of a pyc file loaded entirely into > memory, and I have a pointer to t

Re: importing pyc from memory?

2005-07-04 Thread Derek van Vliet
The second method you describe sounds like it is along the lines of what I need to do. Is there a way to do this using the Python/C API? For instance, if I have the contents of a pyc file loaded entirely into memory, and I have a pointer to the beginning of the file and the size in bytes at my dis

Re: importing pyc from memory?

2005-07-04 Thread Derek van Vliet
Up to now, I've had all my python scripts defined in XML elements, which were compiled when my program started up using Py_CompileString. This has worked great, but I'm finding that most of the time my app uses to start up is spent in that Py_CompileString, because of the large number of scripts th

Re: importing pyc from memory?

2005-07-04 Thread Robert
"Derek van Vliet" <[EMAIL PROTECTED]> schrieb im Newsbeitrag news:[EMAIL PROTECTED] > Using the Python/C API, is there a way I can import a pyc file that I > have in memory (as opposed to loading from disk)? > > I'm trying to save compiled python code in a proprietary file format to > cut reduce t

Re: importing pyc from memory?

2005-07-04 Thread Sybren Stuvel
Derek van Vliet enlightened us with: > I'm trying to save compiled python code in a proprietary file format > to cut reduce the overhead of compiling all my scripts when my app > starts up. Why is that faster than having the .pyc files ready on your filesystem? And why do you want it in a propriet

importing pyc from memory?

2005-07-04 Thread Derek van Vliet
Using the Python/C API, is there a way I can import a pyc file that I have in memory (as opposed to loading from disk)? I'm trying to save compiled python code in a proprietary file format to cut reduce the overhead of compiling all my scripts when my app starts up. Derek -- http://mail.python.