Re: [Numpy-discussion] numpy and C99

2009-10-23 Thread David Cournapeau
On Fri, Oct 23, 2009 at 11:41 PM, Sturla Molden  wrote:

> Except for automatic arrays, they do support some of the more important
> parts of C99 as extensions to C89:
>
> inline functions
> restrict qualifier
> for (int i=0; i<; i++)

No, it doesn't. The above only works in C++ mode, not in C mode.
Visual Studio supports almost none of the useful C99 (VL array,
complex number). The VS team has clearly stated that they don't care
about updating C support.

David
___
NumPy-Discussion mailing list
NumPy-Discussion@scipy.org
http://mail.scipy.org/mailman/listinfo/numpy-discussion


Re: [Numpy-discussion] numpy and C99

2009-10-23 Thread Gael Varoquaux
On Fri, Oct 23, 2009 at 09:47:58AM -0600, Charles R Harris wrote:
>However, I think some code, say loops.c.src, looks better in C than it
>would in cython. C is a rather nice language for that sort of thing. OTOH,
>the ufunc_object.c code might look better in cython. In general, I think a
>separation between pure C code and python interface code would be the way
>to go, with the latter written in cython.

I have some demand in house to be able to use the C parts of numpy for C.
Say for instance you are coding a Python library, with a C-optimized
Monte-Carlo sampler. Linking to the C code of randomkit is very useful
for this. Right now the only way to do this is to copy the randomkit
source and to ship it with your libary, however, hopefully, this will
change in the long run.

So I guess this is a +1 to keep some core numerical functionality in C,
most probably for ABI reasons.

My 2 cents,

Ga�l
___
NumPy-Discussion mailing list
NumPy-Discussion@scipy.org
http://mail.scipy.org/mailman/listinfo/numpy-discussion


Re: [Numpy-discussion] numpy and C99

2009-10-23 Thread Charles R Harris
On Fri, Oct 23, 2009 at 8:41 AM, Sturla Molden  wrote:

> Dag Sverre Seljebotn skrev:
>
>
>
> > Microsoft's compilers don't support C99 (or, at least, versions that
> > still has to be used doesn't).
> >
> >
> Except for automatic arrays, they do support some of the more important
> parts of C99 as extensions to C89:
>
> inline functions
> restrict qualifier
> for (int i=0; i<; i++)
>
>
> Personally I think all of NumPy's C base should be moved to Cython. With
> your excellent syntax for PEP 3118 buffers, I see no reason to keep
> NumPy in C. This would make porting to Py3k as well as maintainence
> easier. When Cython can build Sage, it can be used for a smaller project
> like NumPy as well.
>
>
Sage doesn't have the accumulated layers of crud that numpy has. Yet ;)
However, moving parts of the code to cython is certainly one path forward. A
good starting point would probably be to separate ufuncs from ndarrays.
However, I think some code, say loops.c.src, looks better in C than it would
in cython. C is a rather nice language for that sort of thing. OTOH, the
ufunc_object.c code might look better in cython. In general, I think a
separation between pure C code and python interface code would be the way to
go, with the latter written in cython.


> The question of using C89, C99 or C++ would be deferred to the Cython
> compiler. We could use C++ on one platform (MSVC) and C99 on another
> (GCC). We would also get direct support for C99 _Complex and C++
> std::complex<> types.
>
>
How about symbol export control for the modules? I think that is one more
tool that would benefit from a portable interface in cython.

Chuck
___
NumPy-Discussion mailing list
NumPy-Discussion@scipy.org
http://mail.scipy.org/mailman/listinfo/numpy-discussion


Re: [Numpy-discussion] numpy and C99

2009-10-23 Thread Sturla Molden
Dag Sverre Seljebotn skrev:

 

> Microsoft's compilers don't support C99 (or, at least, versions that 
> still has to be used doesn't).
>
>   
Except for automatic arrays, they do support some of the more important 
parts of C99 as extensions to C89:

inline functions
restrict qualifier
for (int i=0; i<; i++)


Personally I think all of NumPy's C base should be moved to Cython. With 
your excellent syntax for PEP 3118 buffers, I see no reason to keep 
NumPy in C. This would make porting to Py3k as well as maintainence 
easier. When Cython can build Sage, it can be used for a smaller project 
like NumPy as well.

The question of using C89, C99 or C++ would be deferred to the Cython 
compiler. We could use C++ on one platform (MSVC) and C99 on another 
(GCC). We would also get direct support for C99 _Complex and C++ 
std::complex<> types.

I'd also suggest that ndarray subclasses memoryview in Py3k.


S.M.
___
NumPy-Discussion mailing list
NumPy-Discussion@scipy.org
http://mail.scipy.org/mailman/listinfo/numpy-discussion


Re: [Numpy-discussion] numpy and C99

2009-10-23 Thread Charles R Harris
On Fri, Oct 23, 2009 at 7:48 AM, Darren Dale  wrote:

> On Fri, Oct 23, 2009 at 9:29 AM, Pauli Virtanen 
> >
> wrote:
> > Fri, 23 Oct 2009 09:21:17 -0400, Darren Dale wrote:
> >> Can we use features of C99 in numpy? For example, can we use "//" style
> >> comments, and C99 for statements "for (int i=0, ...) "?
> >
> > It would be much easier if we could, but so far we have strived for C89
> > compliance. So I guess the answer is "no".
>
> Out of curiosity (I am relatively new to C), what is holding numpy
> back from embracing C99? Why adhere to a 20-year-old standard?
>
>
To clarify: most compilers support the "//" comment style, but some of the
older Sun compilers don't. The main problem on using any of the newer stuff
is portability. Some of the new stuff, like "//", while handy isn't crucial.
What really hurts is not being able to rely on the math library being up to
snuff.

Chuck
___
NumPy-Discussion mailing list
NumPy-Discussion@scipy.org
http://mail.scipy.org/mailman/listinfo/numpy-discussion


Re: [Numpy-discussion] numpy and C99

2009-10-23 Thread David Cournapeau
On Fri, Oct 23, 2009 at 10:21 PM, Darren Dale  wrote:
> Can we use features of C99 in numpy? For example, can we use "//"
> style comments, and C99 for statements "for (int i=0, ...) "?

No, and most likely never will. Even Visual Studio 2010 does not
handle basic C99.

David
___
NumPy-Discussion mailing list
NumPy-Discussion@scipy.org
http://mail.scipy.org/mailman/listinfo/numpy-discussion


Re: [Numpy-discussion] numpy and C99

2009-10-23 Thread Dag Sverre Seljebotn
Darren Dale wrote:
> On Fri, Oct 23, 2009 at 9:29 AM, Pauli Virtanen  wrote:
>   
>> Fri, 23 Oct 2009 09:21:17 -0400, Darren Dale wrote:
>> 
>>> Can we use features of C99 in numpy? For example, can we use "//" style
>>> comments, and C99 for statements "for (int i=0, ...) "?
>>>   
>> It would be much easier if we could, but so far we have strived for C89
>> compliance. So I guess the answer is "no".
>> 
>
> Out of curiosity (I am relatively new to C), what is holding numpy
> back from embracing C99? Why adhere to a 20-year-old standard?
>   
Microsoft's compilers don't support C99 (or, at least, versions that 
still has to be used doesn't).

Dag Sverre
___
NumPy-Discussion mailing list
NumPy-Discussion@scipy.org
http://mail.scipy.org/mailman/listinfo/numpy-discussion


Re: [Numpy-discussion] numpy and C99

2009-10-23 Thread Darren Dale
On Fri, Oct 23, 2009 at 9:29 AM, Pauli Virtanen  wrote:
> Fri, 23 Oct 2009 09:21:17 -0400, Darren Dale wrote:
>> Can we use features of C99 in numpy? For example, can we use "//" style
>> comments, and C99 for statements "for (int i=0, ...) "?
>
> It would be much easier if we could, but so far we have strived for C89
> compliance. So I guess the answer is "no".

Out of curiosity (I am relatively new to C), what is holding numpy
back from embracing C99? Why adhere to a 20-year-old standard?

Darren
___
NumPy-Discussion mailing list
NumPy-Discussion@scipy.org
http://mail.scipy.org/mailman/listinfo/numpy-discussion


Re: [Numpy-discussion] numpy and C99

2009-10-23 Thread Pauli Virtanen
Fri, 23 Oct 2009 09:21:17 -0400, Darren Dale wrote:
> Can we use features of C99 in numpy? For example, can we use "//" style
> comments, and C99 for statements "for (int i=0, ...) "?

It would be much easier if we could, but so far we have strived for C89 
compliance. So I guess the answer is "no".

-- 
Pauli Virtanen

___
NumPy-Discussion mailing list
NumPy-Discussion@scipy.org
http://mail.scipy.org/mailman/listinfo/numpy-discussion