<SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
 This notebook uses cython, which requires a C compiler. Linux comes with a compiler. Install xcode for OSX and Visual Studio for windows.
Step1:  Sum up an array of numbers using python
Step2:  Use cython, without changing the code
Step3:  Does making s a local variable help?
<ASSISTANT_TASK:>
Python Code:
%load_ext cython
import array
a = array.array('l',range(100))
s = 0
Explanation: This notebook uses cython, which requires a C compiler. Linux comes with a compiler. Install xcode for OSX and Visual Studio for windows.
End of explanation
def python_sum(a):
    global s
    s = 0
    for i in range(len(a)):
        for j in range(10000):
            s = s + a[i]
    return s
%timeit python_sum(a)
Explanation: Sum up an array of numbers using python
End of explanation
%%cython --annotate
def cython_sum1(a):
    global s
    s = 0
    for i in range(len(a)):
        for j in range(10000):
            s = s + a[i]
    return s
print('python sum: ',python_sum(a))
print('cython sum1: ',cython_sum1(a))
print('python sum')
%timeit python_sum(a)
print('cython sum1')
%timeit cython_sum1(a)
Explanation: Use cython, without changing the code
End of explanation
%%cython --annotate
def cython_sum2(a):
    s = 0
    for i in range(len(a)):
        for j in range(10000):
            s = s + a[i]
    return s
print('python sum: ',python_sum(a))
print('cython sum1: ',cython_sum1(a))
print('cython sum2: ',cython_sum2(a))
print('python sum')
%timeit python_sum(a)
print('cython sum1')
%timeit cython_sum1(a)
print('cython sum2')
%timeit cython_sum2(a)
%%cython --annotate
from cpython cimport array
def cython_sum3(a):
    cdef long s = 0
    cdef array.array ta = a
    cdef long * ap = ta.data.as_longs
    for i in range(len(ta)):
        for j in range(10000):
            s = s + ap[i]
    return s
print('python sum: ',python_sum(a))
print('cython sum1: ',cython_sum1(a))
print('cython sum2: ',cython_sum2(a))
print('cython sum3: ',cython_sum3(a))
print('python sum')
%timeit python_sum(a)
print('cython sum1')
%timeit cython_sum1(a)
print('cython sum2')
%timeit cython_sum2(a)
print('cython sum3')
%timeit cython_sum3(a)
from numba import jit
@jit
def numba_sum(a):
    s = 0
    for i in range(len(a)):
        for j in range(10000):
            s = s + a[i]
    return s
print('python sum: ',python_sum(a))
print('cython sum1: ',cython_sum1(a))
print('cython sum2: ',cython_sum2(a))
print('cython sum3: ',cython_sum3(a))
print('numba sum: ', numba_sum(a))
print('python sum')
%timeit python_sum(a)
print('cython sum1')
%timeit cython_sum1(a)
print('cython sum2')
%timeit cython_sum2(a)
print('cython sum3')
%timeit cython_sum3(a)
print('numba sum')
%timeit numba_sum(a)
Explanation: Does making s a local variable help?
End of explanation
<END_TASK>