On Dec 1, 2008, at 10:52 AM, Craig Citro wrote: >> Question for all: is there a good reason for writing cdef >> functions? Or >> should we make all cython functions cpdef? Python convention >> seems to >> be to expose the internals of the class, but just mark (with "_" or >> "__") the functions that are considered internal and may change >> without >> warning. >> > > There are definitely some cases where you have to -- for instance, if > the return type of your function is something like "int *", you're not > going to be able to cpdef that. (Or, if you can, it's news to me.) I'm > sure there are other reasons -- Rob will probably chime in with some > as I'm typing this message. :)
Not only the return type, but also the arguments can't be pointers or other more complicated C types for cpdef functions. There is also a bit of overhead (typically one or two pointer compares) for cpdef functions (as opposed to simple cdef functions) but unless you're doing something very simple it's usually negligible. > That said, there are a *huge* number of functions that do just need > "cdef" turned into "cpdef" in the sage library. Yep, for sure. > >> I'm facing the doctesting dilemma brought up here with some other >> cdef >> functions in another class. >> > > Yeah, I agree that seeing "def _doctest_this_cdef_function" and > writing a little wrapper can be annoying, but I just don't think > there's another way around it in some cases. > > -cc > > > --~--~---------~--~----~------------~-------~--~----~ To post to this group, send email to sage-support@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/sage-support URLs: http://www.sagemath.org -~----------~----~----~----~------~----~------~--~---