Commit 7c022bd9 authored by gsamain's avatar gsamain

cypclass type inference unit test

parent 1752ae4e
cdef cypclass SomeMemory:
int a
void __init__(self, int a=0):
self.a = a
SomeMemory __add__(self, SomeMemory other):
return SomeMemory(self.a + other.a)
SomeMemory __iadd__(self, SomeMemory other):
self.a += other.a
SomeMemory __mul__(self, SomeMemory other):
return SomeMemory(self.a * other.a)
cdef cypclass SomeSubMemory(SomeMemory):
int b
cpdef bag():
o1 = SomeMemory()
o2 = SomeMemory(4)
o3 = SomeSubMemory(3)
o3 += o2
o1 = o2 * o3
return str(o1.a) + '\n' + str(o2.a) + '\n' + str(o3.a)
from distutils.core import setup
from distutils.extension import Extension
from Cython.Build import cythonize
setup(
ext_modules = cythonize([
Extension(
'cypclass_test_type_inference',
language='c++',
sources=['cypclass_test_type_inference.pyx'],
extra_compile_args=["-pthread", "-std=c++11"],
),
])
)
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment