Author: Remi Meier <[email protected]>
Branch: 
Changeset: r342:1b2b48c6a787
Date: 2015-11-18 14:46 +0100
http://bitbucket.org/pypy/benchmarks/changeset/1b2b48c6a787/

Log:    fix use of wrong data structure

diff --git a/multithread/lee_routing/lee_router_tm.py 
b/multithread/lee_routing/lee_router_tm.py
--- a/multithread/lee_routing/lee_router_tm.py
+++ b/multithread/lee_routing/lee_router_tm.py
@@ -58,11 +58,14 @@
 #  * Use optimized STMQueue from pypystm module instead of
 #    hand-written WorkQueue.
 #
-
+#  * Use a deque() where Java used a Vector. deque is much better
+#    to pop an element from the front and append at the end.
+#
 
 import time
 import sys, math
 import threading
+import collections
 
 try:
     from pypystm import atomic, hint_commit_soon
@@ -302,8 +305,8 @@
         #
         # g[x_goal][y_goal][0] = EMPTY; // set goal as empty
        # g[x_goal][y_goal][1] = EMPTY; // set goal as empty
-        front = []
-        tmp_front = []
+        front = collections.deque()#[]
+        tmp_front = collections.deque()#[]
         tempgrid[x, y, 0] = 1
         tempgrid[x, y, 1] = 1
         #
@@ -313,7 +316,7 @@
         reached0, reached1 = False, False
         while front:
             while front:
-                fx, fy, fz, fdw = front.pop(0)
+                fx, fy, fz, fdw = front.popleft()
                 #
                 if fdw > 0:
                     tmp_front.append((fx, fy, fz, fdw - 1))
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to