[Zodb-checkins] CVS: ZODB3/ZODB - fspack.py:1.13

Jeremy Hylton jeremy at zope.com
Thu Oct 2 20:33:07 EDT 2003


Update of /cvs-repository/ZODB3/ZODB
In directory cvs.zope.org:/tmp/cvs-serv14792/ZODB

Modified Files:
	fspack.py 
Log Message:
Make classes with __slots__ into new-style objects.

Move two class variable definitions into __init__(), because class
variables defined in __slots__ are immutable.  This should still be a
net memory savings, because the a 8-entry dict and a 10-entry dict
both have the same allocated size.


=== ZODB3/ZODB/fspack.py 1.12 => 1.13 ===
--- ZODB3/ZODB/fspack.py:1.12	Thu Oct  2 18:14:04 2003
+++ ZODB3/ZODB/fspack.py	Thu Oct  2 20:33:06 2003
@@ -195,7 +195,7 @@
 def DataHeaderFromString(s):
     return DataHeader(*struct.unpack(DATA_HDR, s))
 
-class DataHeader:
+class DataHeader(object):
     """Header for a data record."""
 
     __slots__ = (
@@ -203,10 +203,9 @@
         # These three attributes are only defined when vlen > 0
         "pnv", "vprev", "version")
 
-    version = ""
-    back = 0
-
     def __init__(self, oid, serial, prev, tloc, vlen, plen):
+        self.back = 0 # default
+        self.version = "" # default
         self.oid = oid
         self.serial = serial
         if isinstance(prev, StringType):
@@ -251,7 +250,7 @@
 def TxnHeaderFromString(s):
     return TxnHeader(*struct.unpack(TRANS_HDR, s))
 
-class TxnHeader:
+class TxnHeader(object):
     """Header for a transaction record."""
 
     __slots__ = ("tid", "tlen", "status", "user", "descr", "ext",




More information about the Zodb-checkins mailing list