[Cython] Syntax for declaring Cython class variables

2009-06-02 Thread Juha Salo
Hi, I got a simple problem regarding so called class variables in Cython. I'm trying to declare a simple counter as a class variable which is shared between all instances of that class. The counter's value should be incremented as instances of the class are created. Cython allows me to declare a

Re: [Cython] Syntax for declaring Cython class variables

2009-06-02 Thread Cristi Constantin
Good day. You should try self.count += 1 instead of Foo.count += 1. --- On Tue, 6/2/09, Juha Salo jusa...@gmail.com wrote: From: Juha Salo jusa...@gmail.com Subject: [Cython] Syntax for declaring Cython class variables To: cython-dev@codespeak.net Date: Tuesday, June 2, 2009, 3:43 AM Hi,  I

Re: [Cython] Syntax for declaring Cython class variables

2009-06-02 Thread Juha Salo
Unfortunately that didn't seem to work. I got the following error after the change: a = Foo() Traceback (most recent call last): File stdin, line 1, in module File foo.pyx, line 7, in foo.Foo.__cinit__ (foo.c:388) self.count += 1 AttributeError: 'foo.Foo' object attribute 'count' is

[Cython] PATCH: get rid of __Pyx_StrEq hackery at __Pyx_Method_ClassMethod

2009-06-02 Thread Lisandro Dalcin
Review this. Tell me if you like it. AFAIK, this should always work (even iff an embedder plays with loading/unloading the Python shared library ??) diff -r 88fa346e169d Cython/Compiler/Symtab.py --- a/Cython/Compiler/Symtab.py Tue May 26 22:54:46 2009 +0200 +++ b/Cython/Compiler/Symtab.py Tue

Re: [Cython] Syntax for declaring Cython class variables

2009-06-02 Thread Chris Colbert
This is correct, forget what I said. I should have tried it out before I said anything. My apologies. On Tue, Jun 2, 2009 at 12:44 PM, Lisandro Dalcin dalc...@gmail.com wrote: No, that will not work. AFAIK, Class attributes are not currently supported for cdef classes. Juha, you will have

Re: [Cython] Syntax for declaring Cython class variables

2009-06-02 Thread Lisandro Dalcin
On Tue, Jun 2, 2009 at 2:48 PM, Juha Salo jusa...@gmail.com wrote: OK, thanks for the info. It's interesting, though, that I can code something like this in Cython and it works: cdef class Foo:     foos = {}     def __cinit__(self, name):         Foo.foos[name] = self a = Foo('Larry') b

Re: [Cython] Syntax for declaring Cython class variables

2009-06-02 Thread Stefan Behnel
Sebastien Binet wrote: On Tuesday 02 June 2009 20:03:25 Lisandro Dalcin wrote: On Tue, Jun 2, 2009 at 2:48 PM, Juha Salo wrote: OK, thanks for the info. It's interesting, though, that I can code something like this in Cython and it works: cdef class Foo: foos = {} def

[Cython] testsuite on Py3.1rc1 - everyting failing

2009-06-02 Thread Lisandro Dalcin
No time right now to look at this... All doctests fail on Py3.1rc1, with errors like the traceback below. Are we needing a (trivial?) fix or is something broken on Py3.1? == ERROR: compiling (cpp) and running withstat