Re: [Cython] Strange bug? with np.int64_t

2014-11-03 Thread Stefan Behnel
Patrick Snape schrieb am 15.10.2014 um 20:27:
> To reproduce:
> 
> # distutils: language = c++
> import numpy as np
> cimport numpy as np
> cimport cython
> 
> 
> cdef test_np_int64(const np.int64_t test_var):
> cdef np.int64_t error = test_var / 2
> 
> 
> This fails to compile with the error:
> 
> In function ‘const __pyx_t_5numpy_int64_t
>   __Pyx_div___pyx_t_5numpy_int64_t__const__(__pyx_t_5numpy_int64_t,
> __pyx_t_5numpy_int64_t)’:
> error: assignment of read-only variable ‘q’
>  q -= ((r != 0) & ((r ^ b) < 0));
> 
> 
> Using just a regular int type:
> 
> # distutils: language = c++
> import numpy as np
> cimport numpy as np
> cimport cython
> 
> 
> cdef test_int(const int test_var):
> cdef int no_error = test_var / 2
> 
> Works as expected.
> 
> Fixing this is as simple as removing the const that is being complained
> about. I assume this is a bug?

Yes, looks like a bug to me. Thanks for reporting it.

Stefan

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


[Cython] [FEATURE REQUEST] VisualBasic "Option Explicit" / Perl "use strict" -- bringing variable pre-declaration to cython optionally

2014-11-03 Thread Zaxebo Yaxebo
Subject: [FEATURE REQUEST] VisualBasic "Option Explicit" / Perl "use
strict" -- bringing variable pre-declaration to cython optionally

===
Background:
already cython supports the following:
   #program1
a1  = cython.declare(cython.int) # cdef int a1
a2  = cython.declare(cython.double,0.57721) # cdef double a2 =0.57721
   #end program1

The New Feature Request:

but will there be  - a feature in cython, in which - even though we are
"not" declaring "data types" of variables, but we are declaring variables
themselves. like:

   #program2
   cython.option_strict(True) ##
<--- see this statement
a1  = cython.declare(cython.int) # cdef int a1
a2  = cython.declare(cython.double,0.57721) # cdef double a2 =0.57721
a3 = cython.declare(cython.var) #cdef var a3  ##
<--- see this statement
a4 = cython.declare(cython.var,0.57721) #cdef var a4=0.57721  ##
<--- see this statement


a3 = 10 # <- This statement will not give error
b1 = 10 # <- This statement will give
warning/error, as variable b1 was not declared and cython.option_strict()
is enabled
   #end program2
-

Here we have declared the variables a3 and a4 using "cdef var", but we have
not declared their data types. For a1 and a2, we have declared their
datatypes too.
  But now, as cython.option_strict() is enabled(i.e., true);

  HENCE "b1=10"  statement will give error when cython compiles,
because "b1" variable which was not declared in any sense using
"cython.declare(cython.var) or cdef var" .

  But "a3 = 10" statement in above program will not warning/error,as
"a3" is already declared var

NOTE: This feature request is analogous to VisualBasic's "Option Explicit"
and perl's "use strict"

==
Here are other people also requesting the similar thing:
http://stackoverflow.com/questions/613364/is-there-a-need-for-a-use-strict-python-compiler
http://stackoverflow.com/questions/13425715/does-python-have-a-use-strict-and-use-warnings-like-in-perl
http://stevesprogramming.blogspot.in/2013/03/why-python-needs-perls-use-strict.html
http://bytes.com/topic/python/answers/632587-python-feature-request-explicit-variable-declarations


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