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

Re: [pygame] From * import * and Pygame2exe



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.

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?

On 7/17/05, Richard Jones <richardjones@xxxxxxxxxxxxxxxx> wrote:
> On Mon, 18 Jul 2005 05:42 am, andrew baker wrote:
> > I'm working on my map data portion of my game engine.  The map is
> > broken up into a series of files, each describing a "room".  One
> > technique I've considered to make loading them easier is to import
> > them as a module using "from", such as "from roomxy import *", with
> > the roomxy being a dynamic path to module.  Then, each time the player
> > enters a room, the new room module is imported, overriding the older
> > imported data.
> 
> Modules, once imported, stay in memory. You may not want this (otherwise, why
> not just import them at startup?)
> 
> Something I learnt a long time ago (the hard way) was that Python's module
> loading mechanisms are really good for loading modules and organising them.
> Python's exec() and execfile() functions are really good for running
> arbitrary python code. Don't use one where you can use the other :)
> 
> 
>     Richard
> 
> 
> 


-- 
Andrew Ulysses Baker
"failrate"