Skip to content

Instantly share code, notes, and snippets.

@MarcCote
Created August 13, 2014 13:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save MarcCote/8ea8bb5d31bea8d5da66 to your computer and use it in GitHub Desktop.
Save MarcCote/8ea8bb5d31bea8d5da66 to your computer and use it in GitHub Desktop.
Problem when using fused type with class inheritance in Cython
ctypedef float[:,:] float2d
ctypedef double[:,:] double2d
ctypedef fused Line:
float2d
double2d
cdef class Metric:
cdef float dist(Metric self, Line line) nogil:
pass
cdef class SubMetric(Metric):
pass
# -- setup.py --
import numpy as np
from setuptools import setup
from Cython.Distutils import build_ext
from numpy.distutils.extension import Extension
setup(
cmdclass={'build_ext': build_ext},
ext_modules=[Extension("metric",
["metric.pyx"],
language='c++',
include_dirs=[np.get_include()])
]
)
@jjerphan
Copy link

jjerphan commented Jul 6, 2021

I've been able to compile this reproducer with Cython 0.29.23.

@MarcCote
Copy link
Author

MarcCote commented Jul 6, 2021

Great news! Now I need to remember why I needed that for exactly ^_^.

@jjerphan
Copy link

jjerphan commented Jul 6, 2021

You posted this snippet in this Cython-users group thread. :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment