On 01/24/2013 03:13 PM, Christian Inci wrote:
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Subject: Feature Request: expand list/tuple in 'if (... in ...):' ...

expand list/tuple in 'if (... in ...):' on compile-time if the list/tuple 
contains only static values.

test1: list is expanded manually.
test2: list is not expanded.

The output of the testcase is:
test1: timediff: 0.205533
test2: timediff: 17.567185


Testcase:

from time import time

cdef tuple INT_TUPLE = (0x66, 0x67, 0x2e,
                  0x36, 0x3e, 0x26, 0x64,
                  0x65, 0xf2, 0xf3, 0xf0)

How do you know that INT_TUPLE isn't reassigned to something else?

Dag Sverre


cpdef test():
     cdef unsigned int i
     cdef unsigned short j # 'unsigned char j' won't work for some reason
     cdef double start_time
     start_time = time()
     for i in range(0x50000):
         for j in range(256):
             if (j == 0x66 or j == 0x67 or j == 0x2e or j == 0x36 or j == 0x3e 
or j == 0x26 or j == 0x64 or j == 0x65 or j == 0xf2 or j == 0xf3 or j == 0xf0):
                 pass
     print("test1: timediff: {0:f}".format(time()-start_time))
     start_time = time()
     for i in range(0x50000):
         for j in range(256):
             if (j in INT_TUPLE):
                 pass
     print("test2: timediff: {0:f}".format(time()-start_time))
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.19 (GNU/Linux)
Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/

iQIcBAEBAgAGBQJRAUGQAAoJEDfL/pqB6n6NG90P/jWKAw1vjEO1cyem2teyYIce
cGWbewGJ14VJycztcnZG6XSNzIC0lLMbeu5edUwmr6ObPD0ic0ncGmuKVcsbUIHe
8JmVOgCxaTl2HnH3BNcvUHmsVeAL5PSyIOch80uOG7Nsh7OjZrQ8fAFqITGHzKy9
wb+C/pO1wF8xj+W9BJ5eYlvUYJLx/t/PZxFExrqrAGUxwlsqDqzoPbQsvvDAW1fB
JAMUCR/mLWTQhILOYd1Dvt8gw5uFaiyqqR12f3IOC7yh3xVo3qR3CKFneH4LzuXG
7h7Y8DICXG5xm++kwjBKDbNB+p0o2Z4D56TxdNETxO2vzjnrkIspNhrMpWucvWo3
Wi6qM56W9/2KSupvdpbaOpE0rS1QZxS8v04tpB19c85omCJRDTLlu7Yark7iwo9t
M+GZ0sS8CnqD1delky4T/JBT0tWMqGncXX9fWs0FNIjwOtzVY1QnsGmoEl7Sr2wG
jPZRrSr2gPoDE9J3+fvGceZF9qEPe9+PDA7boetokxvVS6+mFI3IsPc3wC50uHsz
27gnUH0WovUT7iIcxj/8NACejaaPCR6To9ozfhJbsLEh6YzQc+rQajw/Ag3jr933
LuyEK93PYAVQ2391aPBIDeBcDO0oKvy71foWV3sTTVyu7kKnPLRxtVsXbRv6cfQX
1f5O4GM8SzT1HuNvwMS6
=z5IY
-----END PGP SIGNATURE-----
_______________________________________________
cython-devel mailing list
cython-devel@python.org
http://mail.python.org/mailman/listinfo/cython-devel


_______________________________________________
cython-devel mailing list
cython-devel@python.org
http://mail.python.org/mailman/listinfo/cython-devel

Reply via email to