%load_ext Cython
%%cython
cdef class InvalRequestExt:
cdef int ino
cdef char attr_only
def __cinit__(self, ino, attr_only):
self.ino = ino
self.attr_only = bool(attr_only)
from collections import namedtuple
InvalRequestTup = namedtuple('InvalRequestTup', [ 'inode', 'attr_only' ])
def test(cls):
inst = []
for i in range(500):
inst.append(cls(i, False))
return inst
assert len(test(InvalRequestExt)) == len(test(InvalRequestTup))
%timeit test(InvalRequestExt)
%timeit test(InvalRequestTup)