Re: [Cython] Rewriting/compiling parts of CPython's stdlib in Cython

2011-03-28 Thread Robert Bradshaw
On Sun, Mar 27, 2011 at 3:39 PM, Sturla Molden  wrote:
> Den 25.03.2011 19:03, skrev Robert Bradshaw:
>>
 Looking at Guido's comment, Cython must be able to compile all valid
 Python if this will have any chance of success.
>>
>> Good thing that's our goal (pending an actual definition of "all valid
>> Python.")
>>
>
> In lack of a Python language specification it can be hard to tell
> implementation details from syntax. It sounded though as if Guido was
> worried about Cython's compatibility with Python, and maybe the Cython dev
> team's attitude to Python compatibility.

We are very concerned about Python compatibility.

> Also don't think Cython's main strength in this context was properly
> clarified in the debate. It is easy to over-focus on "speed", when it's
> really a matter of "writing Python C extensions easily" -- i.e. without
> knowing (a lot) about Python's C API, not having to worry about reference
> counting, and the possibility of using Python code as prototype. Cython is,
> without comparison, the easiest way of writing C extensions for Python.
> FWIW, it's easier to use Cython than ctypes. Using Cython instead of the C
> API will also avoid many programming errors, because a compiler does fewer
> mistakes than a human. Those aspects are important to communicate, not just
> "Cython can be as fast as C++".

That is a good point. On the other hand, I don't see re-implementing
working C modules written, though probably valuable from a maintenance
point of view, as compelling of a use case.

- Robert
___
cython-devel mailing list
cython-devel@python.org
http://mail.python.org/mailman/listinfo/cython-devel


Re: [Cython] cython crash: default parameters in methods of template cppclass

2011-03-28 Thread Robert Bradshaw
On Tue, Mar 22, 2011 at 7:21 AM, Simon Anders  wrote:
> Hi,
>
> I found a little bug in Cython 0.14.1.
>
> The following causes the Cython compiler to throw an exception:
>
> ---8<---
> cdef extern from "foo.h":
>   cdef cppclass foo[ T ]:
>      bar( int b = 0 )
>
> cdef foo[ int ] a
> a.bar( 1 )
> ---8<---
>
> The exception is "AttributeError: 'CFuncType' object has no attribute
> 'op_arg_struct'", thrown in line 3044, in generate_result_code. Full stack
> trace attached.
>
> The file compiles without crash if one either
>  - removes the last line, i.e. the call to the class's method, or
>  - removes the template argument, i.e., the "[ T ]" in line 2 and
>      the "[ int ]" in line 5.
>
> Hence, the issue only appears when calling methods of _templated_ classes,
> which have a _default_ value for their argument.

Default arguments in C++ are completely different from default
arguments in Cython, this is our bug for not catching that. You have
to declare this as an overloaded method

cdef extern from "foo.h":
cdef cppclass foo[ T ]:
   bar()
   bar(int)

Btw, unless it returns an object, you probably want to declare the
return type of your methods. Perhaps we should make this a warning for
extern declarations?

- Robert
___
cython-devel mailing list
cython-devel@python.org
http://mail.python.org/mailman/listinfo/cython-devel


Re: [Cython] Rewriting/compiling parts of CPython's stdlib in Cython

2011-03-28 Thread Stefan Behnel

Robert Bradshaw, 29.03.2011 02:09:

I don't see re-implementing
working C modules written, though probably valuable from a maintenance
point of view, as compelling of a use case.


It would be rather helpful for CPython, though. Many stdlib modules lack 
dedicated maintainers, and it's likely easier in the Python world to find a 
maintainer for code that's "mostly Python", than for code that's C plus 
CPython's C-API.


Stefan
___
cython-devel mailing list
cython-devel@python.org
http://mail.python.org/mailman/listinfo/cython-devel