- npstreams.length_hint(obj, default=0)¶
Return an estimate of the number of items in
This is useful for presizing containers when building from an iterable.
If the object supports len(), the result will be exact. Otherwise, it may over- or under-estimate by an arbitrary amount. The result will be an integer >= 0.
>>> from npstreams import length_hint >>> length_hint([1,2,3,4,5]) # Should be exact 5 >>> length_hint(None, default = 15) # Does not implement __length_hint__ 15