You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The major drawback of this pattern is it does not allow multiple data types, because Cython does not allow templated classes (nor is such a concept really meaningful).
Attribute pattern
Have the Python class hold the Cython class as an attribute
cdef class cyClass
...
classClass:
def__init__(self):
self.data = cyClass()
This pattern gives us the ability to support multiple underlying data types, but IMO it's harder to understand and requires a lot of indirect methods like
deff(self):
returnself.data.f()
which adds clutter and maintenance and creates a performance problem (partially mititgated by forwarding_method).
The text was updated successfully, but these errors were encountered:
Currently we have two patterns for Cython classes and it would be nice to be more consistent
Subclass pattern
Have a Cython class as a superclass of the Python class
examples: cyVariables and Variables, cyConstrainedQuadraticModel and ConstrainedQuadraticModel
The major drawback of this pattern is it does not allow multiple data types, because Cython does not allow templated classes (nor is such a concept really meaningful).
Attribute pattern
Have the Python class hold the Cython class as an attribute
examples: cyBQM and BQM
This pattern gives us the ability to support multiple underlying data types, but IMO it's harder to understand and requires a lot of indirect methods like
which adds clutter and maintenance and creates a performance problem (partially mititgated by forwarding_method).
The text was updated successfully, but these errors were encountered: