Re: [Cython] Bindings performance issue

2011-06-04 Thread Vitja Makarov
I've tried that: https://github.com/vitek/cython/compare/master..._bindings

Results are not bad: 168 failing tests for pyregr2.7 and 463 for py3

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


Re: [Cython] Bindings performance issue

2011-06-04 Thread mark florisson
On 4 June 2011 12:24, Vitja Makarov  wrote:
> I've tried that: https://github.com/vitek/cython/compare/master..._bindings
>
> Results are not bad: 168 failing tests for pyregr2.7 and 463 for py3

Nice, it partly duplicates work in my fusedtypes branch but I suppose
it will have to be reworked anyway into a subclass. So this works only
for normal classes right, i.e. not for extension classes? It's also
pickle-able, cool :)

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


Re: [Cython] Bindings performance issue

2011-06-04 Thread Vitja Makarov
2011/6/4 mark florisson :
> On 4 June 2011 12:24, Vitja Makarov  wrote:
>> I've tried that: https://github.com/vitek/cython/compare/master..._bindings
>>
>> Results are not bad: 168 failing tests for pyregr2.7 and 463 for py3
>
> Nice, it partly duplicates work in my fusedtypes branch but I suppose
> it will have to be reworked anyway into a subclass.

Sure. I've taken some code from your branch ;)

> So this works only
> for normal classes right, i.e. not for extension classes? It's also
> pickle-able, cool :)
>

Yes. It works for python classes and python def functions.
__reduce__ only returns function name, so it's possible to
pickle/unpickle it in some cases
but that was enough to fix some broken tests from pyregr.

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


[Cython] Header file bug

2011-06-04 Thread Seth Shannin

Hello all,

First, I tried to post this earlier but am pretty sure it didn't go 
through.  If this is a double, I apologize.


This comes out of a discussion on the cython-users list.  I am getting 
some warnings when using cython to compile a python module and then 
calling into the module from c.


I was able to condense the problem down to a very succinct example.

There are three files of interest:

test.pyx:
--
cdef class foo:
cdef int a
cdef int b
def __init__(foo self, int a, int b):
self.a = a
self.b = b

cdef public void bar(foo x):
print "My_foo", x.a, x.b

cdef public foo make_foo(int a, int b):
return foo(a, b)
--

setup.py:
--
from distutils.core import setup
from distutils.extension import Extension
from Cython.Distutils import build_ext

ext_modules = [Extension("test", ["test.pyx"])]

setup(
  name = 'Hello world app',
  cmdclass = {'build_ext': build_ext},
  ext_modules = ext_modules
)
--
and dummy.c:
-
#include "Python.h"
#include "test.h"

int main(int argc, char** argv){
  Py_Initialize();
  inittest();
  bar(make_foo(1,2));
  return 0;
}
---

I use the following commands to compile and link:
python setup.py build_ext --inplace
gcc -I/usr/include/python2.6 -lpython2.6 -L/usr/include/python2.6/config 
-c dummy.c


The second command generates the following error messages:
In file included from dummy.c:2:
test.h:11: warning: 'struct __pyx_obj_4test_foo' declared inside 
parameter list
test.h:11: warning: its scope is only this definition or declaration, 
which is probably not what you want

dummy.c: In function 'main':
dummy.c:7: warning: passing argument 1 of 'bar' from incompatible 
pointer type
test.h:11: note: expected 'struct __pyx_obj_4test_foo *' but argument is 
of type 'struct __pyx_obj_4test_foo *'


After a bit of digging, I found the problem:
The definition for the struct in question was created in test.c, not 
test.h.
GCC is therefore treating the parameter in test.h as a completely 
separate (and empty) struct declaration.  Luckily, in this case struct 
pointers are being used, so enough mem gets allocated, etc. and 
everything actually ends up working.


That being said, the compiler errors are quite bothersome, and it may be 
that this could cause real errors in more complex programs with more 
interdependencies of types.


I would like to propose as a fix that the struct declaration be 
generated inside the header file instead of the .c file (and on a side 
note, I would personally prefer that the #includes be placed in the 
header file as well).


Thanks for all the work that has been put into this project.  Cython is 
really quite a remarkable tool!


-Seth



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