Robert Bradshaw | 1 Feb 19:50 2012

Re: [Cython] [cython-users] Re: How to find out where an AttributeError is ignored

On Tue, Jan 31, 2012 at 8:30 AM, mark florisson
<markflorisson88 <at> gmail.com> wrote:
> On 31 January 2012 02:12, Robert Bradshaw <robertwb <at> math.washington.edu> wrote:
>> On Fri, Jan 27, 2012 at 1:01 PM, Stefan Behnel <stefan_ml <at> behnel.de> wrote:
>>> Dag Sverre Seljebotn, 27.01.2012 21:03:
>>>> On 01/27/2012 05:58 PM, Stefan Behnel wrote:
>>>>> mark florisson, 27.01.2012 17:30:
>>>>>> On 27 January 2012 16:22, mark florisson<markflorisson88 <at> gmail.com>  wrote:
>>>>>>> On 27 January 2012 15:47, Simon King<simon.king <at> uni-jena.de>  wrote:
>>>>>>>> Hi all,
>>>>>>>>
>>>>>>>> I am still *very* frustrated about the fact that Cython does not tell
>>>>>>>> where the error occurs. Since about one week, I am adding lots and
>>>>>>>> lots of lines into Sage that write a log into some file, so that I get
>>>>>>>> at least some idea where the error occurs. But still: Even these
>>>>>>>> extensive logs do not provide a hint on what exactly is happening.
>>>>>>>>
>>>>>>>> How can I patch Cython such that some more information on the location
>>>>>>>> of the error is printed? I unpacked Sage's Cython spkg, and did "grep -
>>>>>>>> R ignored .", but the code lines containing the word "ignored" did not
>>>>>>>> seem to be the lines that are responsible for printing the warning
>>>>>>>> message
>>>>>>>>    Exception AttributeError: 'PolynomialRing_field_with_category'
>>>>>>>> object has no attribute '_modulus' in  ignored
>>>>>>>>
>>>>>>>> Can you point me to the file in Sage's Cython spkg which is
>>>>>>>> responsible for printing the warning?
>>>>>>>>
>>>>>>>> Best regards,
>>>>>>>> Simon
(Continue reading)

Dimitri Tcaciuc | 2 Feb 01:53 2012
Picon

[Cython] distutils extension pxd problem

Hey everyone,

I bumped into an issue where my .pyx file doesn't see its matching
.pxd file. Here's a build test to show the problem If I change my
target package from `b.a` to just `a`, it works as expected. Running
`cython src/a.pyx` works as expected as well, but not the Extension.

----

PYTHON setup.py build_ext --inplace
PYTHON -c "from b import a"

######## setup.py ########

from distutils.core import setup
from distutils.extension import Extension
from Cython.Distutils import build_ext

ext_modules = [
    Extension("b.a", ["src/a.pyx"])
]

setup(
    cmdclass = {'build_ext': build_ext},
    ext_modules = ext_modules
)

######## b/__init__.py ########

######## src/a.pxd ########
(Continue reading)

Stefan Behnel | 2 Feb 08:11 2012
Picon

Re: [Cython] distutils extension pxd problem

Dimitri Tcaciuc, 02.02.2012 01:53:
> I bumped into an issue where my .pyx file doesn't see its matching
> .pxd file. Here's a build test to show the problem If I change my
> target package from `b.a` to just `a`, it works as expected. Running
> `cython src/a.pyx` works as expected as well, but not the Extension.
> 
> ----
> 
> PYTHON setup.py build_ext --inplace
> PYTHON -c "from b import a"
> 
> ######## setup.py ########
> 
> from distutils.core import setup
> from distutils.extension import Extension
> from Cython.Distutils import build_ext
> 
> ext_modules = [
>     Extension("b.a", ["src/a.pyx"])
> ]
> 
> setup(
>     cmdclass = {'build_ext': build_ext},
>     ext_modules = ext_modules
> )
> 
> ######## b/__init__.py ########
> 
> ######## src/a.pxd ########
> 
(Continue reading)

Dimitri Tcaciuc | 2 Feb 08:12 2012
Picon

Re: [Cython] distutils extension pxd problem

Ok, so I narrowed the problem down to
https://github.com/cython/cython/blob/master/Cython/Compiler/Main.py#L223.
At this point, it looks like if target extension name is `x.y.z`, the
pxd must either be called `x.y.z.pxd` and be located in project root
(I believe this is Pyrex convention?) or be in the exact x/y/z.pxd
directory structure, and each of the parents have to be a package (ie.
contain __init__.[py,pyx,pyd]).

Again, this looks like a problem only if module name is nested. If
this is along the right lines, I'd be happy to make some
clarifications to
http://docs.cython.org/src/userguide/sharing_declarations.html#search-paths-for-definition-files.

It looks like there's a conflict between the Extension name parameter
(which also says where the module gets installed in package tree) and
the name of the actual .so file, which sometimes one needs to
customize (eg. I need to compile x/y/z.pyx to x/y/_z.so since I'd like
to have z.py with some extra bits in them. In this case `cythonize`
seems to ignore the extension name, goes ahead and names the output
`z.so`)

I recon you guys probably had plenty of discussions on this topic. Is
there a general direction where you're taking the whole include/pxd
discovery system or is it staying where it is right now?

Dimitri.

On Wed, Feb 1, 2012 at 4:53 PM, Dimitri Tcaciuc <dtcaciuc@...> wrote:
> Hey everyone,
>
(Continue reading)

Dimitri Tcaciuc | 2 Feb 08:24 2012
Picon

Re: [Cython] distutils extension pxd problem

> Date: Thu, 02 Feb 2012 08:11:16 +0100
> From: Stefan Behnel <stefan_ml@...>
> To: Core developer mailing list of the Cython compiler
>        <cython-devel@...>
> Subject: Re: [Cython] distutils extension pxd problem
> Message-ID: <4F2A3714.7000704@...>
> Content-Type: text/plain; charset=UTF-8
>
> Dimitri Tcaciuc, 02.02.2012 01:53:
>> I bumped into an issue where my .pyx file doesn't see its matching
>> .pxd file. Here's a build test to show the problem If I change my
>> target package from `b.a` to just `a`, it works as expected. Running
>> `cython src/a.pyx` works as expected as well, but not the Extension.
>>
>> ----
>>
>> PYTHON setup.py build_ext --inplace
>> PYTHON -c "from b import a"
>>
>> ######## setup.py ########
>>
>> from distutils.core import setup
>> from distutils.extension import Extension
>> from Cython.Distutils import build_ext
>>
>> ext_modules = [
>>     Extension("b.a", ["src/a.pyx"])
>> ]
>>
>> setup(
(Continue reading)

Stefan Behnel | 2 Feb 09:21 2012
Picon

[Cython] Cython's view on a common benchmark suite (was: Re: [Speed] Buildbot Status)

Brett Cannon, 01.02.2012 18:25:
> to prevent this from either ending up in a dead-end because of this, we
> need to first decide where the canonical set of Python VM benchmarks are
> going to live. I say hg.python.org/benchmarks for two reasons. One is that
> Antoine has already done work there to port some of the benchmarks so there
> is at least some there that are ready to be  run under Python 3 (and the
> tooling is in place to create separate Python 2 and Python 3 benchmark
> suites). Two, this can be a test of having the various VM contributors work
> out of hg.python.org if we are ever going to break the stdlib out for
> shared development. At worst we can simply take the changes made at
> pypy/benchmarks that apply to just the unladen benchmarks that exists, and
> at best merge the two sets (manually) into one benchmark suite so PyPy
> doesn't lose anything for Python 2 measurements that they have written and
> CPython doesn't lose any of its Python 3 benchmarks that it has created.
> 
> How does that sound?

+1

FWIW, Cython currently uses both benchmark suites, that of PyPy (in Py2.7)
and that of hg.python.org (in Py2.7 and 3.3), but without codespeed
integration and also without a dedicated server for benchmark runs. So the
results are unfortunately not accurate enough to spot minor changes even
over time.

https://sage.math.washington.edu:8091/hudson/view/bench/

We would like to join in on speed.python.org, once it's clear how the
benchmarks will be run and how the data uploads work and all that. It
already proved a bit tricky to get Cython integrated with the benchmark
(Continue reading)

Dag Sverre Seljebotn | 2 Feb 13:19 2012
Picon
Picon

[Cython] memoryview slices can't be None?

I just realized that

cdef int[:] a = None

raises an exception; even though I'd argue that 'a' is of the 
"reference" kind of type where Cython usually allow None (i.e., "cdef 
MyClass b = None" is allowed even if type(None) is NoneType). Is this a 
bug or not, and is it possible to do something about it?

Dag Sverre
mark florisson | 2 Feb 22:10 2012
Picon

Re: [Cython] [cython-users] Re: How to find out where an AttributeError is ignored

On 1 February 2012 18:50, Robert Bradshaw <robertwb <at> math.washington.edu> wrote:
> On Tue, Jan 31, 2012 at 8:30 AM, mark florisson
> <markflorisson88 <at> gmail.com> wrote:
>> On 31 January 2012 02:12, Robert Bradshaw <robertwb <at> math.washington.edu> wrote:
>>> On Fri, Jan 27, 2012 at 1:01 PM, Stefan Behnel <stefan_ml <at> behnel.de> wrote:
>>>> Dag Sverre Seljebotn, 27.01.2012 21:03:
>>>>> On 01/27/2012 05:58 PM, Stefan Behnel wrote:
>>>>>> mark florisson, 27.01.2012 17:30:
>>>>>>> On 27 January 2012 16:22, mark florisson<markflorisson88 <at> gmail.com>  wrote:
>>>>>>>> On 27 January 2012 15:47, Simon King<simon.king <at> uni-jena.de>  wrote:
>>>>>>>>> Hi all,
>>>>>>>>>
>>>>>>>>> I am still *very* frustrated about the fact that Cython does not tell
>>>>>>>>> where the error occurs. Since about one week, I am adding lots and
>>>>>>>>> lots of lines into Sage that write a log into some file, so that I get
>>>>>>>>> at least some idea where the error occurs. But still: Even these
>>>>>>>>> extensive logs do not provide a hint on what exactly is happening.
>>>>>>>>>
>>>>>>>>> How can I patch Cython such that some more information on the location
>>>>>>>>> of the error is printed? I unpacked Sage's Cython spkg, and did "grep -
>>>>>>>>> R ignored .", but the code lines containing the word "ignored" did not
>>>>>>>>> seem to be the lines that are responsible for printing the warning
>>>>>>>>> message
>>>>>>>>>    Exception AttributeError: 'PolynomialRing_field_with_category'
>>>>>>>>> object has no attribute '_modulus' in  ignored
>>>>>>>>>
>>>>>>>>> Can you point me to the file in Sage's Cython spkg which is
>>>>>>>>> responsible for printing the warning?
>>>>>>>>>
>>>>>>>>> Best regards,
(Continue reading)

mark florisson | 2 Feb 22:16 2012
Picon

Re: [Cython] memoryview slices can't be None?

On 2 February 2012 12:19, Dag Sverre Seljebotn
<d.s.seljebotn@...> wrote:
> I just realized that
>
> cdef int[:] a = None
>
> raises an exception; even though I'd argue that 'a' is of the "reference"
> kind of type where Cython usually allow None (i.e., "cdef MyClass b = None"
> is allowed even if type(None) is NoneType). Is this a bug or not, and is it
> possible to do something about it?
>
> Dag Sverre
> _______________________________________________
> cython-devel mailing list
> cython-devel@...
> http://mail.python.org/mailman/listinfo/cython-devel

Yeah I disabled that quite early. It was supposed to be working but
gave a lot of trouble in cases (segfaults, mainly). At the time I was
trying to get rid of all the segfaults and get the basic functionality
working, so I disabled it. Personally, I have never liked how things
can be None unchecked. I personally prefer to write

cdef foo(obj=None):
    cdef int[:] a
    if obj is None:
        obj = ...
    a = obj

Often you forget to write 'not None' when declaring the parameter (and
(Continue reading)

Dag Sverre Seljebotn | 2 Feb 22:38 2012
Picon
Picon

Re: [Cython] memoryview slices can't be None?

On 02/02/2012 10:16 PM, mark florisson wrote:
> On 2 February 2012 12:19, Dag Sverre Seljebotn
> <d.s.seljebotn@...>  wrote:
>> I just realized that
>>
>> cdef int[:] a = None
>>
>> raises an exception; even though I'd argue that 'a' is of the "reference"
>> kind of type where Cython usually allow None (i.e., "cdef MyClass b = None"
>> is allowed even if type(None) is NoneType). Is this a bug or not, and is it
>> possible to do something about it?
>>
>> Dag Sverre
>> _______________________________________________
>> cython-devel mailing list
>> cython-devel@...
>> http://mail.python.org/mailman/listinfo/cython-devel
>
> Yeah I disabled that quite early. It was supposed to be working but
> gave a lot of trouble in cases (segfaults, mainly). At the time I was
> trying to get rid of all the segfaults and get the basic functionality
> working, so I disabled it. Personally, I have never liked how things

Well, you can segfault quite easily with

cdef MyClass a = None
print a.field

so it doesn't make sense to slices different from cdef classes IMO.

(Continue reading)


Gmane