char** to {'':('',)}

David Bolen db3l at fitlinxx.com
Wed Aug 29 20:35:50 EDT 2001


Ignacio Vazquez-Abrams <ignacio at openservices.net> writes:

> Unfortunately I have even more pragmatic a reason for doing it in C than
> speed; I get the char** for a library written in C, and some days it's just
> NOT worth using the struct module.

I'm not sure struct would help with a char ** anyway, unless you're
saying that the pointers themselves reference data within the same
contiguous block of memory somehow.

But given that the char ** exists within your module, you could
consider just writing a tiny (simpler) function to take the char **
and directly translate it into a tuple of strings (a single
PyTuple_New and a loop with PyString_FromString), and then let any
further parsing take place at the Python level.

That way you'd get the benefit of the basic required conversion to
Python data types, but wouldn't encode into the C module any further
parsing requirements or dependencies.  Sometimes it's as important to
decide just how much to move to an extension (where to draw the
interface line) as whether to do any work in an extension at all.

--
-- David
-- 
/-----------------------------------------------------------------------\
 \               David Bolen            \   E-mail: db3l at fitlinxx.com  /
  |             FitLinxx, Inc.            \  Phone: (203) 708-5192    |
 /  860 Canal Street, Stamford, CT  06902   \  Fax: (203) 316-5150     \
\-----------------------------------------------------------------------/



More information about the Python-list mailing list