Skip to content

Commit

Permalink
fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
nzjrs committed Apr 13, 2012
1 parent 36e0d3f commit 4908d29
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 16 deletions.
5 changes: 1 addition & 4 deletions week3/lib/prime.py
Expand Up @@ -3,8 +3,6 @@ def primes(kmax):
kmax = 100000
k = 0
n = 2
j = 0
result = [0] * kmax
p = [0] * kmax
while k < kmax:
i = 0
Expand All @@ -13,6 +11,5 @@ def primes(kmax):
if i == k:
p[k] = n
k = k + 1
result[j] = n; j = j + 1
n = n + 1
return result
return p
4 changes: 1 addition & 3 deletions week3/lib/pyxprime.pyx
@@ -1,7 +1,6 @@
def primes(int kmax):
cdef int n, k, i
cdef int p[100000]
result = []
if kmax > 100000:
kmax = 100000
k = 0
Expand All @@ -13,6 +12,5 @@ def primes(int kmax):
if i == k:
p[k] = n
k = k + 1
result.append(n)
n = n + 1
return result
return [p[i] for i in range(kmax)]
14 changes: 7 additions & 7 deletions week3/lib/test.sh
Expand Up @@ -2,25 +2,25 @@

export LD_LIBRARY_PATH=`pwd`

echo testlibprime
echo -e "\ntestlibprime"
time $(./testlibprime >/dev/null)

echo pyxlibprime
echo -e "\npyxlibprime"
time $(python -c 'import pyxlibprime; pyxlibprime.Prime(2000)._print()' > /dev/null)

echo ctlibprime
echo -e "\nctlibprime"
time $(python -c 'import ctlibprime; ctlibprime.Prime(2000)._print()' > /dev/null)

echo pyxprime
echo -e "\npyxprime"
time $(python -c 'import pyxprime; print pyxprime.primes(2000)' > /dev/null)

#echo pyxnpprime
#echo -e "\npyxnpprime"
#time $(python -c 'import pyxnpprime; print pyxnpprime.primes(2000)' > /dev/null)

echo pyprime
echo -e "\npyprime"
time $(python -c 'import pyprime; print pyprime.primes(2000)' > /dev/null)

echo prime
echo -e "\nprime"
time $(python -c 'import prime; print prime.primes(2000)' > /dev/null)


3 changes: 1 addition & 2 deletions week3/presentation.pin
Expand Up @@ -11,12 +11,11 @@ Interfacing with Native code from Python
-- [black] [text-color=white] [font=Sans 40px] [shading-color=black] [shading-opacity=0.66]
Why

✔ speeding up hot loops
✔ speeding up hot loops
✔ interfacing with native libraries
✔ improving performance in multi-threaded applications
✔ interfacing with other computational environments
flexible data structures
enjoying segfaults

-- [slide-contents-exec=source-highlight -s c -i lib/libprime.h -o STDOUT --outlang-def=./pango.outlang]

Expand Down

0 comments on commit 4908d29

Please sign in to comment.