[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

Re: [pygame] From * import * and Pygame2exe



On Mon, 18 Jul 2005 09:15 am, andrew baker wrote:
> Well, in my plan, the room modules just load variables into the FSM.
> It was my understanding that using "from" would place those values in
> the local namespace, and not increase in size unless I introduce new
> variables.

Yes, it imports the vars into your local namespace, but the module will also 
hang around in the sys.modules namespace.


> However, if exec or execfile is considered a better option, how much
> of a speed hit does it take?  Is it noticeable, or just as perky as
> any given module import?

It's as perky as any *fresh* module import - since it's just compiling and 
executing the code just like a module import. Try out an execfile of some 
Python code. Even a long-ish module will compile and start executing in a 
very short space of time. If the module's been compiled, then the module 
import will be faster (it still has to exec, but the compilation is done). 
You can mimic this by using the marshal module (which exists to write 
compiled modules).


    Richard

Attachment: pgpCy9c6gRQFO.pgp
Description: PGP signature