Skip to content

Commit f0831e7

Browse files
committed
Faster isiterable when x isn't iterable.
1 parent 19edc08 commit f0831e7

File tree

1 file changed

+1
-5
lines changed

1 file changed

+1
-5
lines changed

toolz/itertoolz.py

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -283,11 +283,7 @@ def isiterable(x):
283283
>>> isiterable(5)
284284
False
285285
"""
286-
try:
287-
iter(x)
288-
return True
289-
except TypeError:
290-
return False
286+
return hasattr(x, "__iter__")
291287

292288

293289
def isdistinct(seq):

0 commit comments

Comments
 (0)