[Cython] [cython-users] Cython .pxd introspection: listing defined constants

W. Trevor King wking at drexel.edu
Thu Mar 3 01:51:04 CET 2011


On Sat, Feb 26, 2011 at 07:11:48PM -0800, Robert Bradshaw wrote:
> On Sat, Feb 26, 2011 at 6:14 PM, W. Trevor King <wking at drexel.edu> wrote:
> > On Sat, Feb 26, 2011 at 10:01:43AM -0800, Robert Bradshaw wrote:
> >> On Sat, Feb 26, 2011 at 3:48 AM, W. Trevor King <wking at drexel.edu> wrote:
> >> > On Fri, Feb 25, 2011 at 11:11:03PM -0800, Robert Bradshaw wrote:
> >> >> On Tue, Feb 22, 2011 at 12:02 PM, W. Trevor King <wking at drexel.edu> wrote:
> >> >> > An easy, if uglier, workaround would be to prepend attributes with the
> >> >> > class name, e.g. CBinding.visibility -> CBinding.c_binding_visiblity.
> >> >> > Then the Ctx class could subclass the current CtxAttribute classes
> >> >> > instead of binding instances of each of them.  That way Ctx would keep
> >> >> > its traditional flat attribute namespace and easy deepcopy, but
> >> >> > eveyone in Nodes, etc. that will use the attributes would become
> >> >> > class-name dependent.
> >> >>
> >> >> I'd be up for flattening this. In particular, changing every
> >> >> "entry.name" to "entry.python_binding.name" seems to be a lot of churn
> >> >> and extra verbiage for not much benefit. The only overlap I see is
> >> >> name and visibility, and keeping name/cname and adding cvisibility
> >> >> would be preferable to me.
> >> >
> >> > That works for me, but I see possible ambiguity in cname.  From the
> >> > "external C code" docs:
> >> >
> >> >    The other way is to use a C name specification to give different
> >> >    Cython and C names to the C function. Suppose, for example, that
> >> >    you want to wrap an external function called eject_tomato(). If
> >> >    you declare it as:
> >> >
> >> >    cdef extern void c_eject_tomato "eject_tomato" (float speed)
> >> >
> >> >    then its name inside the Cython module will be c_eject_tomato,
> >> >    whereas its name in C will be eject_tomato.
> >> >
> >> > In this case I was eventually going to use
> >> >
> >> >    c_source.name = eject_tomato
> >> >    c_source.namespace = ...
> >> >                c_binding.name = c_eject_tomato
> >> >    c_binding.namespace = ...
> >> >                python_binding.name = eject_tomato
> >> >
> >> > I'm not sure how Cython handles name/cname with this case at the
> >> > moment, but it seems like there are two cnames to keep track of.
> >>
> >> In this case, cname is "eject_tomato" (which actually gets emitted in
> >> the C source file to use it) and name (in both Python and Cython
> >> namespace) is "c_eject_tomato."
> >
> > What is the "Cython namespace"?  Is that what you get when you cimport
> > something (vs. the Python namespace being what you get when you import
> > something).
> 
> Yes, that would be a good way to understand it.

Okay, I'm back to a flat attribute namespace in my branch, and I'm
moving through Nodes removing the places where I currently collapse
back to an overloaded visibility.

-- 
This email may be signed or encrypted with GPG (http://www.gnupg.org).
The GPG signature (if present) will be attached as 'signature.asc'.
For more information, see http://en.wikipedia.org/wiki/Pretty_Good_Privacy

My public key is at http://www.physics.drexel.edu/~wking/pubkey.txt
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 198 bytes
Desc: not available
URL: <http://mail.python.org/pipermail/cython-devel/attachments/20110302/307fcf45/attachment-0001.pgp>


More information about the cython-devel mailing list