Last active
February 3, 2017 19:59
-
-
Save rhyolight/d8d6af7c171ccb36603fe79d29938b34 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def saveSpatialPooler(sp, key): | |
proto = SpatialPoolerProto_capnp.SpatialPoolerProto.new_message() | |
sp.write(proto) | |
bytes = proto.to_bytes_packed() | |
redis.set(key, bytes) | |
def loadSpatialPooler(key): | |
bytes = redis.get(key) | |
proto = SpatialPoolerProto_capnp.SpatialPoolerProto.from_bytes_packed(bytes) | |
return SpatialPooler.read(proto) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Regarding line 11 above, Redis reads are fast, unpacking the bytes into a prototype is fast, but reading the prototype into an object is very slow.