[Pyrex] [Cython-dev] [PATCH] 'include' statements inside 'cdef class' level

Stefan Behnel stefan_ml at behnel.de
Wed Sep 5 09:30:51 CEST 2007


> On Sep 4, 2007, at 5:50 AM, Caio Marcelo wrote:
>> On 9/3/07, Greg Ewing <greg.ewing at canterbury.ac.nz> wrote:
>>> What exactly does "correct" mean here? Do you mean
>>> that the contents of the included file start at an
>>> indentation of zero, or at the same level as the
>>> including code?
>> Thinking about it, both ways are reasonable (i.e. indenting or not the
>> included file). In both cases it will solve my problems, and I  
>> agree that
>> not indenting the included file may have better semantics: "it will  
>> include
>> the content of the other file in the level that the included  
>> statement is",
>> plain and simple. Actually, it would make the change even simpler: the
>> if-statement (the one that calls s2.expect_indent()) would not be  
>> necessary.

Robert Bradshaw *top-posted*:
> If you want to include the same pxi file in multiple classes, that
> will lead to redundant code that could possibly be implemented
> otherwise, and if it is included into only one class I'm not seeing
> the benifit (and it may make things much more difficult to follow--
> I've had some not-so-pleasant experiences trying to understand code
> from include-happy C developers). You clearly have reason in mind for
> wanting this patch, could you please elaborate? Would being able to
> cimport module-level cdef functions solve the problem as well?

Also note the public C-API support in Cython. It allows you to access
functions from external Cython modules at the C level (with a straight
function call), so in combination with the capability of subclassing a type
that is implemented in an external module, I don't really see how class-level
code inclusion is an important feature. I would also ask the OP to elaborate
some more on the actual use cases.

Stefan




More information about the Pyrex mailing list