-
-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
33 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,33 +1,33 @@ | ||
diff --git a/cytoolz/itertoolz.pyx b/cytoolz/itertoolz.pyx | ||
index e138f71..6c5bc88 100644 | ||
--- a/cytoolz/itertoolz.pyx | ||
+++ b/cytoolz/itertoolz.pyx | ||
@@ -960,12 +960,13 @@ cdef class sliding_window: | ||
[1.5, 2.5, 3.5] | ||
""" | ||
def __cinit__(self, Py_ssize_t n, object seq): | ||
cdef Py_ssize_t i | ||
self.iterseq = iter(seq) | ||
self.prev = PyTuple_New(n) | ||
+ PyTuple_SET_ITEM(self.prev, 0, None) | ||
for i, seq in enumerate(islice(self.iterseq, n-1), 1): | ||
Py_INCREF(seq) | ||
PyTuple_SET_ITEM(self.prev, i, seq) | ||
self.n = n | ||
|
||
def __iter__(self): | ||
@@ -1051,12 +1052,14 @@ cdef class partition_all: | ||
i += 1 | ||
if i == self.n: | ||
return result | ||
# iterable exhausted before filling the tuple | ||
if i == 0: | ||
raise StopIteration | ||
+ for j in range(i, self.n): | ||
+ PyTuple_SET_ITEM(result, j, None) | ||
return PyTuple_GetSlice(result, 0, i) | ||
|
||
|
||
cpdef object count(object seq): | ||
""" | ||
Count the number of items in seq | ||
diff --git a/cytoolz/itertoolz.pyx b/cytoolz/itertoolz.pyx | ||
index e138f71..6c5bc88 100644 | ||
--- a/cytoolz/itertoolz.pyx | ||
+++ b/cytoolz/itertoolz.pyx | ||
@@ -960,12 +960,13 @@ cdef class sliding_window: | ||
[1.5, 2.5, 3.5] | ||
""" | ||
def __cinit__(self, Py_ssize_t n, object seq): | ||
cdef Py_ssize_t i | ||
self.iterseq = iter(seq) | ||
self.prev = PyTuple_New(n) | ||
+ PyTuple_SET_ITEM(self.prev, 0, None) | ||
for i, seq in enumerate(islice(self.iterseq, n-1), 1): | ||
Py_INCREF(seq) | ||
PyTuple_SET_ITEM(self.prev, i, seq) | ||
self.n = n | ||
|
||
def __iter__(self): | ||
@@ -1051,12 +1052,14 @@ cdef class partition_all: | ||
i += 1 | ||
if i == self.n: | ||
return result | ||
# iterable exhausted before filling the tuple | ||
if i == 0: | ||
raise StopIteration | ||
+ for j in range(i, self.n): | ||
+ PyTuple_SET_ITEM(result, j, None) | ||
return PyTuple_GetSlice(result, 0, i) | ||
|
||
|
||
cpdef object count(object seq): | ||
""" | ||
Count the number of items in seq |