Cython: share pure python module -


i have 1 pure python module a.py file containing class enhanced cython:

@cython.cclass class test 

how can use class in pure python module b.py? tried from import test cython compiler tells me not type wherever use test in b.py

as said in comments, can using .pxd files in addition .py files specify types in. realise isn't elegant putting in .py files, far know it's best can do.

a.py:

class test:     pass 

a.pxd:

cdef class test:   pass 

b.py:

# here use test in places think want use it: #   function argument #   variable in function #   in class import  def f(x):     return x  def g():     t = a.test()     return t  class c:     pass 

b.pxd:

import cython cimport  cpdef f(a.test x)  @cython.locals(t=a.test) cpdef g()  cdef class c:     cdef a.test t 

you can verify it's using type information correctly inspecting generated b.c file.

for reference, relevant documentation http://docs.cython.org/src/tutorial/pure.html#magic-attributes-within-the-pxd


Comments

Popular posts from this blog

java - Suppress Jboss version details from HTTP error response -

gridview - Yii2 DataPorivider $totalSum for a column -

Sass watch command compiles .scss files before full sftp upload -