A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from http://mail.python.org/pipermail/python-list/2005-September/306768.html below:

Need help with C extension module

Need help with C extension module Need help with C extension modulechris chris.stromberger at gmail.com
Thu Sep 8 12:42:57 EDT 2005
Ok, I found further examples on the Internet and got something working
(it seems), but I have a question about the memory management.  The
example I found did not include any of the PyMem_... functions.

Here's roughly what I have working:

cdef extern from "my.h":
  cdef struct inputs:
    char   *x

  cdef struct outputs:
      int     y

  outputs *func(inputs *x, outputs *y)
  int init(char* fname)

class Analyzer:
  def __init__(self, fname):
    init(fname)

  # inp is my python "Inputs" object.
  def myfunc(self, inp):
    cdef inputs* i
    i.x= inp.x

    cdef outputs* o
    o = func(i, o)
    return o.y

class Inputs:
  def __init__(self):
    self.x = ""

So there is no explicit memory management going on there as in Robert's
example.  Is this ok?  

Thanks,
Chris


More information about the Python-list mailing list

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4