class Memoize(object):
    """
    This is a decorator to allow memoization of function calls. It is a
    completely dumb cache, and will cache anything given to it indefinitely.
    """
    def __init__(self, func):
        self.func = func
        self.cache = {}

    def __call__(self, *args):
        try:
            data, oldframe = self.cache[args]
            self.cache[args] = (data, frame)
            return data
        except KeyError:
            res = self.func(*args)
            self.cache[args] = (res, frame)
            return res
        except TypeError:
            print "WARNING: Unhashable type passed to memoize2. Reconsider using this decorator"
            return self.func(*args)


class SmartMemoize(object):
    """
    This is a decorator to allow memoization of function calls. Its cache
    is cleared on scene changes, and also clears items from the cache which
    haven't been used in at least 250 frames.
    """
    def __init__(self, func):
        self.func = func
        self.cache = {}
        self.scene = None
        self.last_clear = 0

    def __call__(self, *args):
        from spyral import director
        frame = director.get_tick()
        if director.get_scene() is not self.scene:
            self.scene = director.get_scene()
            self.cache = {}
        if frame - self.last_clear > 100:
            for key, value in self.cache.items():
                data, oldframe = value
                if frame - oldframe > 250:
                    self.cache.pop(key)
            self.last_clear = frame
        try:
            data, oldframe = self.cache[args]
            self.cache[args] = (data, frame)
            return data
        except KeyError:
            res = self.func(*args)
            self.cache[args] = (res, frame)
            return res
        except TypeError:
            print "WARNING: Unhashable type passed to memoize2. Reconsider using this decorator"
            return self.func(*args)

@@ -321,110 +321,31 @@
     
-data, oldframe = self.cache%5Bargs%5D%0A            self.cache%5Bargs%5D = (data, frame)%0A            return data
+return self.cache%5Bargs%5D
 %0A   
@@ -428,36 +428,27 @@
 che%5Bargs%5D = 
-(
 res
-, frame)
 %0A           
@@ -538,33 +538,32 @@
 assed to memoize
-2
 . Reconsider usi
@@ -571,32 +571,33 @@
 g this decorator
+.
 %22%0A            re

Fix some copy-pasta cruft that broke the Memoize decorator.