Aug-25-2017, 12:52 PM
(Aug-25-2017, 11:14 AM)DeaD_EyE Wrote: Cool :-)
One small tiny improvement: Put surface_cache (line no 37) into the function.
I wasn't sure what you meant, so I tried it out. I thought only lists worked like that, not dicts. Neat :)
>>> def cached(key, cache={}): ... if key in cache: ... return cache[key] ... print("cache miss!") ... cache[key] = "spam" ... return cache[key] ... >>> cached("eggs") cache miss! 'spam' >>> cached(42) cache miss! 'spam' >>> cached("eggs") 'spam'Either way, I'm not sure it's needed. It just felt a little wasteful to have 1000 copies of the exact same thing in memory, so blitting one copy in multiple places felt better lol