Fernando Perez | 1 Oct 2008 01:59
Picon
Gravatar

Re: [Cython] docs.cython.org

On Tue, Sep 30, 2008 at 10:35 AM, Robert Bradshaw
<robertwb@...> wrote:

>> b) A script to build them is shipped with Cython (setup.py could do
>> this
>> I suppose)
>
> If Sphinx is detected, and it's fast. I certainly don't want it to be
> a requirement.

Please feel free to pillage anything from the ipython sources you may
want for this.  We build the docs only when
'sdist' or 'bdist_rpm' are given, so that only package distributors
need to have the toolchain installed:

http://bazaar.launchpad.net/%7Eipython-dev/ipython/trunk/annotate/1147?file_id=setup.py-20080216095032-xb0is4a97lmosv2z-14

lines 97-120.

There's also a bit of nasty trickery in

http://bazaar.launchpad.net/%7Eipython-dev/ipython/trunk/annotate/1147?file_id=setupbase.py-20080606221622-xwbqrw3mlwq01vyb-1

line 146, func make_dir_struct() to be able to easily produce the
necessary data layout for distutils to ship the nested doc tree.

You guys already have the makefile and sphinx code, but take any of
this you may find useful.

Anything for better docs :)
(Continue reading)

Uwe Schmitt | 1 Oct 2008 13:08
Picon
Gravatar

[Cython] pyximport

Hi,

I had trouble to import pyximport and found
only two postings about this problem from august.

The problem was that "import pyximport" fails,
which I could fix (as suggested in the postings
above) by making pyximport/ a python packgage,
which means I had to add a "__init__.py" file to
.../site-packages/cython.../pyximport/

I wonder that I found not more about that.
Is nobody using pyximport or did I miss something ?

Greetings, Uwe

--

-- 
Dr. rer. nat. Uwe Schmitt
F&E Mathematik

mineway GmbH
Science Park 2
D-66123 Saarbrücken

Telefon: +49 (0)681 8390 5334
Telefax: +49 (0)681 830 4376

uschmitt@...
www.mineway.de

(Continue reading)

Lisandro Dalcin | 1 Oct 2008 15:47
Picon
Gravatar

Re: [Cython] pyximport

On Wed, Oct 1, 2008 at 8:08 AM, Uwe Schmitt <uschmitt@...> wrote:
> The problem was that "import pyximport" fails,
> which I could fix (as suggested in the postings
> above) by making pyximport/ a python packgage,
> which means I had to add a "__init__.py" file to
> .../site-packages/cython.../pyximport/

Yes, add a __init__.py file with the following line inside 'from
pyximport import *'

This still need to be fixed in cython-devel repo. I'll try to make a patch.

--

-- 
Lisandro Dalcín
---------------
Centro Internacional de Métodos Computacionales en Ingeniería (CIMEC)
Instituto de Desarrollo Tecnológico para la Industria Química (INTEC)
Consejo Nacional de Investigaciones Científicas y Técnicas (CONICET)
PTLC - Güemes 3450, (3000) Santa Fe, Argentina
Tel/Fax: +54-(0)342-451.1594
Lisandro Dalcin | 1 Oct 2008 15:52
Picon
Gravatar

[Cython] PATCH: fix pyximport installation as a package

This should fix the installation of pyximport as a package. Please,
review and apply.

-- 
Lisandro Dalcín
---------------
Centro Internacional de Métodos Computacionales en Ingeniería (CIMEC)
Instituto de Desarrollo Tecnológico para la Industria Química (INTEC)
Consejo Nacional de Investigaciones Científicas y Técnicas (CONICET)
PTLC - Güemes 3450, (3000) Santa Fe, Argentina
Tel/Fax: +54-(0)342-451.1594
Attachment (pyximport.diff): text/x-patch, 383 bytes
This should fix the installation of pyximport as a package. Please,
review and apply.

--

-- 
Lisandro Dalcín
---------------
Centro Internacional de Métodos Computacionales en Ingeniería (CIMEC)
Instituto de Desarrollo Tecnológico para la Industria Química (INTEC)
Consejo Nacional de Investigaciones Científicas y Técnicas (CONICET)
PTLC - Güemes 3450, (3000) Santa Fe, Argentina
Tel/Fax: +54-(0)342-451.1594
Lisandro Dalcin | 1 Oct 2008 20:13
Picon
Gravatar

[Cython] cython leaks references to Py_None for cdef'ed globals

Consider the following code inside a one-line pyx file:

cdef object someint = 7

Then Cython generates the following inside the module init function:

  /*--- Global init code ---*/
  __pyx_v_9refleaks2_someint = Py_None; Py_INCREF(Py_None);

  /* "/u/dalcinl/Devel/Cython/sandbox/refleaks2.pyx":1
 * cdef object someint = 7             # <<<<<<<<<<<<<<
 *
 */
  Py_INCREF(__pyx_int_7);
  __pyx_v_9refleaks2_someint = __pyx_int_7;

Clearly, Py_None references are being leaked. All this is because of
bad interaction between this two methods:

* ModuleNode.generate_global_init_code(...) (in ModuleNode.py)
* FinalOptimizePhase.visit_SingleAssignmentNode(...) (in Optimize.py)

--

-- 
Lisandro Dalcín
---------------
Centro Internacional de Métodos Computacionales en Ingeniería (CIMEC)
Instituto de Desarrollo Tecnológico para la Industria Química (INTEC)
Consejo Nacional de Investigaciones Científicas y Técnicas (CONICET)
PTLC - Güemes 3450, (3000) Santa Fe, Argentina
Tel/Fax: +54-(0)342-451.1594
(Continue reading)

Lisandro Dalcin | 1 Oct 2008 20:19
Picon
Gravatar

Re: [Cython] cython leaks references to Py_None for cdef'ed globals

BTW, this patch fix the issue by not initializing cdef'ed module
globals to None. But this is not the safest approach (I can imagine
some nasty ways to originate segfaults). Perhaps we should try to fix
the isue in FinalOptimizePhase.visit_SingleAssignmentNode

On Wed, Oct 1, 2008 at 3:13 PM, Lisandro Dalcin <dalcinl@...> wrote:
> Consider the following code inside a one-line pyx file:
>
> cdef object someint = 7
>
> Then Cython generates the following inside the module init function:
>
>  /*--- Global init code ---*/
>  __pyx_v_9refleaks2_someint = Py_None; Py_INCREF(Py_None);
>
>  /* "/u/dalcinl/Devel/Cython/sandbox/refleaks2.pyx":1
>  * cdef object someint = 7             # <<<<<<<<<<<<<<
>  *
>  */
>  Py_INCREF(__pyx_int_7);
>  __pyx_v_9refleaks2_someint = __pyx_int_7;
>
>
> Clearly, Py_None references are being leaked. All this is because of
> bad interaction between this two methods:
>
> * ModuleNode.generate_global_init_code(...) (in ModuleNode.py)
> * FinalOptimizePhase.visit_SingleAssignmentNode(...) (in Optimize.py)
>
>
(Continue reading)

Thomas Keller | 1 Oct 2008 20:29
Picon

[Cython] cython doesn't compile cdef'd variables of type set?

This may be a foolish question, but I'm still getting used to to
Cython. I was under the impression that you can cdef all the basic
python types like list, dict,tuple etc. However, when I try to cdef variables
of type set, Cython gives a compile error. Is it simply unsupported at
this time or am I completely missing something? I imagine either way
it wouldn't speed things up that much.
Regards,
Thomas Keller
Lisandro Dalcin | 1 Oct 2008 21:08
Picon
Gravatar

Re: [Cython] cython doesn't compile cdef'd variables of type set?

Dear Thomas,

This should be fixed in 'cython-devel' repo. All numeric, string and
container builtin types (plus slice and file) are supported for all
Python versions. Let us know if you give a try to cython-devel and
something does not work.

Of course,  in Py2.3 your C compiler will fail if you use 'set',
perhaps this could be emulated somewhat with sets.Set and
set.InmutableSet, but I do not tried that when I wrote the patch
fixing your problem.

Regards,

On Wed, Oct 1, 2008 at 3:29 PM, Thomas Keller
<thomas.e.keller@...> wrote:
> This may be a foolish question, but I'm still getting used to to
> Cython. I was under the impression that you can cdef all the basic
> python types like list, dict,tuple etc. However, when I try to cdef variables
> of type set, Cython gives a compile error. Is it simply unsupported at
> this time or am I completely missing something? I imagine either way
> it wouldn't speed things up that much.
> Regards,
> Thomas Keller
> _______________________________________________
> Cython-dev mailing list
> Cython-dev@...
> http://codespeak.net/mailman/listinfo/cython-dev
>

(Continue reading)

Dag Sverre Seljebotn | 1 Oct 2008 21:28
Picon
Picon

Re: [Cython] cython leaks references to Py_None for cdef'ed globals

I say let them leak? The only real risk (that I can see at least) is overflowing the refcount, and if I
understand and remember an informal chat correctly even that is eliminated in newer Python versions
where Py_None and friends have special deallocation which never deallocate...

Dag Sverre Seljebotn
-----Original Message-----
From: "Lisandro Dalcin" <dalcinl@...>
Date: Wednesday, Oct 1, 2008 8:20 pm
Subject: Re: [Cython] cython leaks references to Py_None for cdef'ed globals
To: cython-dev <cython-dev@...>Reply-To: cython-dev@...

BTW, this patch fix the issue by not initializing cdef'ed module
>globals to None. But this is not the safest approach (I can imagine
>some nasty ways to originate segfaults). Perhaps we should try to fix
>the isue in FinalOptimizePhase.visit_SingleAssignmentNode
>
>On Wed, Oct 1, 2008 at 3:13 PM, Lisandro Dalcin <dalcinl@...> wrote:
>> Consider the following code inside a one-line pyx file:
>>
>> cdef object someint = 7
>>
>> Then Cython generates the following inside the module init function:
>>
>>  /*--- Global init code ---*/
>>  __pyx_v_9refleaks2_someint = Py_None; Py_INCREF(Py_None);
>>
>>  /* "/u/dalcinl/Devel/Cython/sandbox/refleaks2.pyx":1
>>  * cdef object someint = 7             # <<<<<<<<<<<<<<
>>  *
>>  */
(Continue reading)

Michael Abshoff | 1 Oct 2008 21:34

Re: [Cython] cython leaks references to Py_None for cdef'ed globals

Dag Sverre Seljebotn wrote:

Hi,

> I say let them leak? The only real risk (that I can see at least) is overflowing the refcount,
 > and if I understand and remember an informal chat correctly even that 
is eliminated in newer
 > Python versions where Py_None and friends have special deallocation 
which never deallocate...

I have had the pleasure to debug refcount reference overflows and let me 
say it is not something I would like to repeat since it happened only on 
32 bit test systems (the count would also wraps on a 64 bit box, but 
that would take a while longer). So I would highly suggest to fix any 
reference count leak since you never want code to crash for stupid 
reasons like this.

> Dag Sverre Seljebotn

<SNIP>

Cheers,

Michael

Gmane