Skip to content

Commit 7df6070

Browse files
feat: cdef aliases to eliminate global lookups
1 parent ab8d4b6 commit 7df6070

File tree

1 file changed

+20
-5
lines changed

1 file changed

+20
-5
lines changed

cytoolz/itertoolz.pyx

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,26 @@ from cpython.tuple cimport PyTuple_GET_ITEM, PyTuple_GetSlice, PyTuple_New, PyTu
1010
# Locally defined bindings that differ from `cython.cpython` bindings
1111
from cytoolz.cpython cimport PtrIter_Next, PtrObject_GetItem
1212

13-
from collections import deque
14-
from heapq import heapify, heappop, heapreplace
15-
from itertools import chain, islice, zip_longest
16-
from operator import itemgetter
17-
from cytoolz.utils import no_default
13+
import collections
14+
import heapq
15+
import itertools
16+
import operator
17+
from cytools import utils
18+
19+
# cdef aliases to eliminate global lookups
20+
cdef object deque = collections.deque
21+
22+
cdef object heapify = heapq.heapify
23+
cdef object heappop = heapq.heappop
24+
cdef object heapreplace = heapq.heapreplace
25+
26+
cdef object chain = itertools.chain
27+
cdef object islice = itertools.islice
28+
cdef object zip_longest = itertools.zip_longest
29+
30+
cdef object itemgetter = operator.itemgetter
31+
32+
cdef object no_default = utils.no_default
1833

1934

2035
__all__ = ['remove', 'accumulate', 'groupby', 'merge_sorted', 'interleave',

0 commit comments

Comments
 (0)