[Cython] code generated for arguments of type "type"

2012-07-18 Thread Stefan Behnel
Hi,

the following pull request tries to fix the fact that we currently generate
arguments of type "PyObject*" when someone spells out "type" for them.

https://github.com/cython/cython/pull/126

That's mostly a problem in CPython's C-API, but also in some NumPy
functions. The correct way to translate this would be as a "PyTypeObject*",
not a bare "PyObject*".

Does anyone see a general problem with changing this in the compiler
directly? I'm not sure that it won't break code, for example. We'll at
least have to cast the arguments on the way in as well.

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


Re: [Cython] 2d buffer interface with aligned data

2012-07-18 Thread Christian Heimes
Am 17.07.2012 22:55, schrieb Christian Heimes:
> Either I'm doing something wrong or I found a Cython bug. I've attached
> two files. The output is unexpected and looks like something is
> accessing uninitialized memory:

For the record:
It's my fault. The shade and stripes Py_ssize_t* arrays can't be local
variables. I've to malloc() two arrays and free() them in
__releasebuffer__(). Cython is so easy to use, it makes me forget all
this little annoying C things.

Christian

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


Re: [Cython] 2d buffer interface with aligned data

2012-07-18 Thread Christian Heimes
Am 18.07.2012 07:18, schrieb Stefan Behnel:
> BTW, note that your question is better suited for the Cython users mailing
> list than the core developer mailing list.

I'm sorry. I didn't know Cython had a user list, too. Thanks Stefan!

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


Re: [Cython] 2d buffer interface with aligned data

2012-07-18 Thread Dag Sverre Seljebotn
If the image will always be 2D, you can add

cdef Py_ssize_t shape[2]

To your cdef class and assign self.shape to the Py_buffer. This is a bit more 
efficient.

Dag
-- 
Sent from my Android phone with K-9 Mail. Please excuse my brevity.

Christian Heimes  wrote:

Am 17.07.2012 22:55, schrieb Christian Heimes:
> Either I'm doing something wrong or I found a Cython bug. I've attached
> two files. The output is unexpected and looks like something is
> accessing uninitialized memory:

For the record:
It's my fault. The shade and stripes Py_ssize_t* arrays can't be local
variables. I've to malloc() two arrays and free() them in
__releasebuffer__(). Cython is so easy to use, it makes me forget all
this little annoying C things.

Christian

_

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] known? 0.16 on varioius platforms: ValueError: Buffer dtype mismatch, expected 'char' but got 'unsigned char' in ...

2012-07-18 Thread Yaroslav Halchenko

On Tue, 17 Jul 2012, Yaroslav Halchenko wrote:
> I have tested on a sparc box and current master seems to not show this
> particular problem (see below though) -- does anyone remember this
> particular issue and commit which fixed it?

I am sorry -- I got lost among architectures and what fails where and possibly
misguided you in my original report -- current master does still have this
problem -- this time testing on s390x (it does pass on sparc):

(s390x-sid)yoh@zelenka:~/cython/cython$ python runtests.py -vv 
memoryview_compare_type_pointers
Python 2.7.3 (default, Jul 14 2012, 05:19:55) 
[GCC 4.6.3]

Running tests against Cython 0.17pre 0cbc0f4398cb0edbc7a128cfb2b72567f2e5e217
/home/yoh/cython/cython/BUILD/support/temp.linux-s390x-2.7/pyrex/refnanny.c: In 
function ‘__pyx_f_8refnanny_report_unraisable’:
/home/yoh/cython/cython/BUILD/support/temp.linux-s390x-2.7/pyrex/refnanny.c:2309:7:
 warning: variable ‘__pyx_clineno’ set but not used [-Wunused-but-set-variable]
/home/yoh/cython/cython/BUILD/support/temp.linux-s390x-2.7/pyrex/refnanny.c:2308:15:
 warning: variable ‘__pyx_filename’ set but not used [-Wunused-but-set-variable]
/home/yoh/cython/cython/BUILD/support/temp.linux-s390x-2.7/pyrex/refnanny.c:2307:7:
 warning: variable ‘__pyx_lineno’ set but not used [-Wunused-but-set-variable]
Backends: c,cpp

runTest (__main__.EndToEndTest)
End-to-end memoryview_compare_type_pointers ... /usr/bin/python setup.py 
build_ext --inplace
Compiling test_compare_type_pointers.pyx because it changed.
Compiling other_module.pyx because it changed.
Cythonizing other_module.pyx
Cythonizing test_compare_type_pointers.pyx
running build_ext
building 'test_compare_type_pointers' extension
creating build
creating build/temp.linux-s390x-2.7
gcc -pthread -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall 
-Wstrict-prototypes -fPIC -I/usr/include/python2.7 -c 
test_compare_type_pointers.c -o 
build/temp.linux-s390x-2.7/test_compare_type_pointers.o
gcc -pthread -shared -Wl,-O1 -Wl,-Bsymbolic-functions -Wl,-z,relro 
build/temp.linux-s390x-2.7/test_compare_type_pointers.o -o 
/home/yoh/cython/cython/BUILD/memoryview/memoryview_compare_type_pointers/test_compare_type_pointers.so
building 'other_module' extension
gcc -pthread -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall 
-Wstrict-prototypes -fPIC -I/usr/include/python2.7 -c other_module.c -o 
build/temp.linux-s390x-2.7/other_module.o
gcc -pthread -shared -Wl,-O1 -Wl,-Bsymbolic-functions -Wl,-z,relro 
build/temp.linux-s390x-2.7/other_module.o -o 
/home/yoh/cython/cython/BUILD/memoryview/memoryview_compare_type_pointers/other_module.so

test_compare_type_pointers.c:1040:1: warning: useless type name in empty 
declaration [enabled by default]
test_compare_type_pointers.c:1042:1: warning: useless type name in empty 
declaration [enabled by default]
other_module.c:1038:1: warning: useless type name in empty declaration [enabled 
by default]
other_module.c:1040:1: warning: useless type name in empty declaration [enabled 
by default]
other_module.c:1044:1: warning: useless type name in empty declaration [enabled 
by default]
Traceback (most recent call last):
  File "", line 1, in 
  File "test_compare_type_pointers.pyx", line 3, in init 
test_compare_type_pointers (test_compare_type_pointers.c:13542)
import other_module
  File "other_module.pyx", line 4, in init other_module (other_module.c:13350)
cdef Foo[:] fooview = fooarray
ValueError: Buffer dtype mismatch, expected 'char' but got 'unsigned char' in 
'Foo.c'

FAIL

==
FAIL: runTest (__main__.EndToEndTest)
End-to-end memoryview_compare_type_pointers
--
Traceback (most recent call last):
  File "runtests.py", line 1100, in runTest
self.assertEqual(0, res, "non-zero exit status")
AssertionError: non-zero exit status

--
Ran 1 test in 11.070s

FAILED (failures=1)
ALL DONE

-- 
Yaroslav O. Halchenko
Postdoctoral Fellow,   Department of Psychological and Brain Sciences
Dartmouth College, 419 Moore Hall, Hinman Box 6207, Hanover, NH 03755
Phone: +1 (603) 646-9834   Fax: +1 (603) 646-1419
WWW:   http://www.linkedin.com/in/yarik
___
cython-devel mailing list
cython-devel@python.org
http://mail.python.org/mailman/listinfo/cython-devel