title: Is there a way to call a cdef class method that has non-pythonic arguments?
body: <p>Effectively, I am cleaning up a cython module that has many globally scoped functions and variables. I thought cdef classes would be a great way to package some of these functions. But I ran into an issue when trying to call some of the methods of these classes. I boilded it down to these two examples that show my issue. The functionality of the code is unimportant, I am just trying to demonstrate the problem I am facing.</p>
  <pre><code>cdef class Foo:
      def __init__(self):
          pass
  
      cdef int deref(self, int *bar):
          return bar[0]
  
  cdef int bar = 5
  foo = Foo()
  foo.deref(&amp;bar)
  </code></pre>
  <p>If I run this code I get an error</p>
  <blockquote>
  <p>Cannot convert 'int *' to Python object</p>
  </blockquote>
  <p>But If I define everything in global scope it works just fine:</p>
  <pre><code>cdef int deref(int *bar):
      return bar[0]
  cdef int bar = 5
  deref(&amp;bar)
  </code></pre>
  <p>My question is: Is it possible to call a cdef method in this mannor?</p>
  <p>My thought was that it would work since it is all being done within cython, but for some reason cython wants to convert the pointer into a python object and then back into a cython object? Is this always the case? I thought cdef classes were an effective tool to use when using cython.</p>
  <p>Anyways, I have exhausted my attempts at solving this issue myself and wanted to ask here before abandoning cdef classes and going back to functional programming.</p>