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

Re: [pygame] Best way to access data



On 11 Jul 2006 at 10:27, Brian Fisher wrote:

> > I had a question as to which way would be better to access data after
> > loading it into memory.
> >
> your cache looks fine
> 
> On 7/11/06, Lenard Lindstrom <len-l@xxxxxxxxx> wrote:
> > Leave out the unnecessary cache and assign directly to global
> > variables.
> >
> I wouldn't do things that way. Having an image cache object can be a
> very good thing if you want to call functions to see what is loaded,
> check the size of loaded images or unload all cached images. If they
> are just sitting in globals, it can be awkward to do those things.
> 
Good points.The same benefit of using globals can be achieved with a:

from play import cache

Actually it is faster. The only other change I would suggest is 
making the cache key independent of the file type by dropping the 
'.png' suffix.

Lenard Lindstrom
<len-l@xxxxxxxxx>