Denis Bilenko  committed ecb4e40

Greenlet: store links as deque instead of list

This fixes links execution order to be the same as they were added, fixing issue #143
The microbenchmarks show that it's not slower, in fact, a bit faster.

  • Participants
  • Parent commits c503c63

Comments (0)

Files changed (1)

File gevent/

 import sys
 from gevent.hub import greenlet, getcurrent, get_hub, GreenletExit, Waiter, PY3
 from gevent.timeout import Timeout
+from collections import deque
 __all__ = ['Greenlet',
             self._run = run
         self.args = args
         self.kwargs = kwargs
-        self._links = []
+        self._links = deque()
         self.value = None
         self._exception = _NONE
         loop = hub.loop
     def _notify_links(self):
         while self._links:
-            link = self._links.pop()
+            link = self._links.popleft()