lundi 9 mars 2015

Cython: a class needs to have as its attribute a python list of Cython extension types -- thus, this class cannot be an extension type itself?

Let us say I have a Cython extension type named Point.


Then, I need to create a class called Points, which has as one of its attributes, a Python list of Point objects. Now, Python lists, as far as I understand, cannot be attributes of an extension type, as only C data types can be.


I want to use Python lists to hold the list of Cython extension types, because I have heard that its the easiest way to do so, and access of Python lists through Cython is quit efficient.


Thus, Points has to be a normal Python/Cython class, not an extension type, correct? That way, I can do the following:



def class Points:
def __init__(self, num_points):
self.points = [Point() for x in range(num_points)]


Do I understand correctly?


Aucun commentaire:

Enregistrer un commentaire