/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to breezy/_simple_set_pyx.pyx

  • Committer: Jelmer Vernooij
  • Date: 2017-06-10 21:59:15 UTC
  • mto: This revision was merged to the branch mainline in revision 6690.
  • Revision ID: jelmer@jelmer.uk-20170610215915-zcpu0in3r1irx3ml
Move serializer to bzr.

Show diffs side-by-side

added added

removed removed

Lines of Context:
16
16
 
17
17
"""Definition of a class that is similar to Set with some small changes."""
18
18
 
 
19
from __future__ import absolute_import
 
20
 
19
21
cdef extern from "python-compat.h":
20
22
    pass
21
23
 
115
117
            raise MemoryError()
116
118
        memset(self._table, 0, n_bytes)
117
119
 
 
120
    def __sizeof__(self):
 
121
        # Note: Pyrex doesn't allow sizeof(class) so we re-implement it here.
 
122
        # Bits are:
 
123
        #   1: PyObject
 
124
        #   2: vtable *
 
125
        #   3: 3 Py_ssize_t
 
126
        #   4: PyObject**
 
127
        # Note that we might get alignment, etc, wrong, but at least this is
 
128
        # better than no estimate at all
 
129
        # return sizeof(SimpleSet) + (self._mask + 1) * (sizeof(PyObject*))
 
130
        return (sizeof(PyObject) + sizeof(void*)
 
131
                + 3*sizeof(Py_ssize_t) + sizeof(PyObject**)
 
132
                + (self._mask + 1) * sizeof(PyObject*))
 
133
 
118
134
    def __dealloc__(self):
119
135
        if self._table != NULL:
120
136
            PyMem_Free(self._table)