pysize icon indicating copy to clipboard operation
pysize copied to clipboard

Exception on OrderedDict with > 1000 items

Open hvtuananh opened this issue 7 years ago • 1 comments

OrderedDict is a special case. It has the same behavior as dict, but being treated as a custom object in get_size

Python 2.7.13 (default, Dec 23 2016, 05:05:58) 
[GCC 4.2.1 Compatible Apple LLVM 8.0.0 (clang-800.0.38)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> from pysize import get_size
>>> from collections import OrderedDict
>>> a = OrderedDict()
>>> for i in xrange(1000):
...     a[i] = i
... 
>>> len(a)
1000
>>> try:
...     get_size(a)
... except Exception as e:
...     print(e)
... 
maximum recursion depth exceeded while calling a Python object

hvtuananh avatar Jun 23 '17 21:06 hvtuananh

@hvtuananh Apologies for the delay - can you clarify how is it a special case?

Also, I will change this algorithm to use an iterative approach. For now if you are blocked you can use sys.setrecursionlimit. Good catch!

bosswissam avatar Oct 09 '17 06:10 bosswissam