Permalink
Browse files

changed pickle protocol to 2 for more efficient pickling of new style…

… classes
  • Loading branch information...
1 parent 171cea4 commit 3fef5043a8ca365555e00efe4d0d5d63d1e36386 @virhilo virhilo committed Mar 15, 2013
@@ -47,7 +47,7 @@ def __contains__(self, key):
def set_value(self, key, value, expiretime=None):
key = self._format_key(key)
- self.cf.insert(key, {'data': pickle.dumps(value)}, ttl=expiretime)
+ self.cf.insert(key, {'data': pickle.dumps(value, 2)}, ttl=expiretime)
def __getitem__(self, key):
try:
@@ -57,7 +57,7 @@ def has_key(self, key):
return key in self
def set_value(self, key, value):
- self.db_conn[self._format_key(key)] = pickle.dumps(value)
+ self.db_conn[self._format_key(key)] = pickle.dumps(value, 2)
def __setitem__(self, key, value):
self.set_value(key, value)
@@ -54,9 +54,9 @@ def set_value(self, key, value, expiretime=None):
expiretime = value[1]
if expiretime:
- self.db_conn.setex(key, expiretime, pickle.dumps(value))
+ self.db_conn.setex(key, expiretime, pickle.dumps(value, 2))
else:
- self.db_conn.set(key, pickle.dumps(value))
+ self.db_conn.set(key, pickle.dumps(value, 2))
def __delitem__(self, key):
self.db_conn.delete(self._format_key(key))
@@ -27,7 +27,7 @@ def __getitem__(self, key):
return pickle.loads(self.db_conn.get(self.domain, self._format_key(key)))
def set_value(self, key, value):
- self.db_conn.put(self.domain, self._format_key(key), pickle.dumps(value))
+ self.db_conn.put(self.domain, self._format_key(key), pickle.dumps(value, 2))
def __delitem__(self, key):
raise Exception("Unimplemented")
@@ -24,7 +24,7 @@ def __contains__(self, key):
return self.db_conn.has_key(self._format_key(key))
def set_value(self, key, value):
- self.db_conn[self._format_key(key)] = pickle.dumps(value)
+ self.db_conn[self._format_key(key)] = pickle.dumps(value, 2)
def __delitem__(self, key):
del self.db_conn[self._format_key(key)]

0 comments on commit 3fef504

Please sign in to comment.