Addendum: I tried to define __weakref__ and __dealloc__, but this did nothing to solve the issue.
2015-06-15 12:34 GMT+02:00 Stephen LARROQUE <lrq3...@gmail.com>: > Hello, > > I am trying to make an extension type inheriting from int or cython.int (to > do arithmetic operations in Galois Fields). However, this causes a > MemoryError because it seems such extension type is not freed correctly. > Other than that, it works perfectly well. > > Here is a test case to reproduce the bug on Python 2.7.9 Win32 (I'm > running Windows 7, but it may happen on other platform, I did not test) > with Cython v0.22 on Anaconda: > > ######################## > # mode: run > > import sys > > cdef class ExtendedInt(int): pass > > _ERRORS = u""" > MemoryError > """ > > # Simple test case to raise a MemoryError by generating lots of ExtendedInt > total_it = 1000 > for i in xrange(total_it): > for j in xrange(10000000): > ExtendedInt(j) > sys.stdout.write("\rGenerating lists of ExtendedInt : %i/%i" % (i, > total_it)) > ######################## > > My current workaround as advised in the cython-users list: > https://groups.google.com/forum/#!topic/cython-users/WJ5BJ5moAh4 > > is to inherit from standard (object) and then reimplement all int magic > methods, which is cumbersome and less optimized, but at least there's no > MemoryError. > >
_______________________________________________ cython-devel mailing list cython-devel@python.org https://mail.python.org/mailman/listinfo/cython-devel