Skip to content

TypeError bug in core/base.py when used with memory profilers. #13546

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
ericmjl opened this issue Jul 1, 2016 · 1 comment
Closed

TypeError bug in core/base.py when used with memory profilers. #13546

ericmjl opened this issue Jul 1, 2016 · 1 comment
Labels
Duplicate Report Duplicate issue or pull request

Comments

@ericmjl
Copy link

ericmjl commented Jul 1, 2016

I have been trying to use some memory profiling tools, to profile my code. With two different memory profilers, both of which use sys.getsizeof(obj), pandas has been the cause of a TypeError returned. I am posting below an example using the memory-tools package.

Code Sample

I have tested the following code independently in a Jupyter notebook environment, separate from my other code. It should (hopefully) be a minimal example that can be reproduced. I am happy to provide more information on my environment if needed.

from memorytools import summarize_objects
import pandas as pd
summarize_objects()

Error Returned

---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-2-c46dbac041c7> in <module>()
----> 1 summarize_objects()

/Users/ericmjl/Documents/github/memory-tools/src/memorytools/__init__.py in summarize_objects(objs, echo, limit)
     90     objs = gc.get_objects()
     91 
---> 92   objs_dict = _summarize_objects(objs)
     93   size_summary = ['{0:>10s} {1:>5s} {2}'.format('Size', 'Count', 'Type')]
     94   count_summary = ['{0:>5s} {1:>10s} {2}'.format('Count', 'Size', 'Type')]

/Users/ericmjl/Documents/github/memory-tools/src/memorytools/__init__.py in _summarize_objects(objs)
    133   for obj in objs:
    134     _incr(objs_dict, type(obj), 'count')
--> 135     _incr(objs_dict, type(obj), 'size', sys.getsizeof(obj))
    136 
    137   return objs_dict

/Users/ericmjl/anaconda/lib/python3.5/site-packages/pandas/core/base.py in __sizeof__(self)
    128         # no memory_usage attribute, so fall back to
    129         # object's 'sizeof'
--> 130         return super(self, PandasObject).__sizeof__()
    131 
    132 

TypeError: must be type, not FrozenList

Please pardon my ignorance on this matter, but would someone be kind enough to educate me on why this error is thrown, and how I might be able to fix this? If there's a maintainer who could provide some guidance, I am happy to dig into the codebase and submit a PR if that will fix the error.

output of pd.show_versions()

INSTALLED VERSIONS
------------------
commit: None
python: 3.5.1.final.0
python-bits: 64
OS: Darwin
OS-release: 15.5.0
machine: x86_64
processor: i386
byteorder: little
LC_ALL: None
LANG: en_CA.UTF-8

pandas: 0.18.1
nose: 1.3.7
pip: 8.1.2
setuptools: 18.2
Cython: 0.23.4
numpy: 1.11.0
scipy: 0.17.1
statsmodels: 0.6.1
xarray: None
IPython: 4.1.1
sphinx: 1.3.5
patsy: 0.4.1
dateutil: 2.4.2
pytz: 2015.4
blosc: None
bottleneck: 1.0.0
tables: None
numexpr: None
matplotlib: 1.4.3
openpyxl: 2.3.2
xlrd: 0.9.4
xlwt: 1.0.0
xlsxwriter: 0.8.4
lxml: 3.6.0
bs4: 4.4.1
html5lib: None
httplib2: None
apiclient: None
sqlalchemy: 1.0.12
pymysql: None
psycopg2: None
jinja2: 2.8
boto: 2.39.0
pandas_datareader: None
@ericmjl ericmjl changed the title A bug in core/base.py TypeError bug in core/base.py when used with memory profilers. Jul 1, 2016
@jreback
Copy link
Contributor

jreback commented Jul 1, 2016

closed by #12924

@jreback jreback closed this as completed Jul 1, 2016
@jreback jreback added Duplicate Report Duplicate issue or pull request API Design labels Jul 1, 2016
@jorisvandenbossche jorisvandenbossche added this to the No action milestone Jul 2, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Duplicate Report Duplicate issue or pull request
Projects
None yet
Development

No branches or pull requests

3 participants