Rev 5367: We also have to re-implement it for _simple_set_pyx.pyx in http://bazaar.launchpad.net/~jameinel/bzr/2.3-sizeof

John Arbash Meinel john at arbash-meinel.com
Mon Aug 2 18:16:21 BST 2010


At http://bazaar.launchpad.net/~jameinel/bzr/2.3-sizeof

------------------------------------------------------------
revno: 5367
revision-id: john at arbash-meinel.com-20100802171612-rdh5ods70w2bl3j7
parent: john at arbash-meinel.com-20100802170829-l0ti5v5rvcua32ia
committer: John Arbash Meinel <john at arbash-meinel.com>
branch nick: 2.3-sizeof
timestamp: Mon 2010-08-02 12:16:12 -0500
message:
  We also have to re-implement it for _simple_set_pyx.pyx
-------------- next part --------------
=== modified file 'bzrlib/_simple_set_pyx.pyx'
--- a/bzrlib/_simple_set_pyx.pyx	2010-07-28 21:36:44 +0000
+++ b/bzrlib/_simple_set_pyx.pyx	2010-08-02 17:16:12 +0000
@@ -116,7 +116,18 @@
         memset(self._table, 0, n_bytes)
 
     def __sizeof__(self):
-        return sizeof(SimpleSet) + (self._mask + 1) * (sizeof(PyObject**))
+        # Note: Pyrex doesn't allow sizeof(class) so we re-implement it here.
+        # Bits are:
+        #   1: PyObject
+        #   2: vtable *
+        #   3: 3 Py_ssize_t
+        #   4: PyObject**
+        # Note that we might get alignment, etc, wrong, but at least this is
+        # better than no estimate at all
+        # return sizeof(SimpleSet) + (self._mask + 1) * (sizeof(PyObject*))
+        return (sizeof(PyObject) + sizeof(void*)
+                + 3*sizeof(Py_ssize_t) + sizeof(PyObject**)
+                + (self._mask + 1) * sizeof(PyObject*))
 
     def __dealloc__(self):
         if self._table != NULL:



More information about the bazaar-commits mailing list