pympler: asizeof(obj) leads to a negative base ValueError

I am trying to estimate the size of a python object that is a subclass of an astropy.Table

However, I receive a ValueError: invalid option: base=-391848 error.

Does anyone have suggestions on why this is occurring/how I can fix this?

MWE:

%pip install -q lightkurve
%pip install -q pympler

import lightkurve as lk
from pympler import asizeof
import numpy as np
import os

lc = lk.search_lightcurve("TOI 588", author="SPOC").download_all().stitch().remove_nans()
asizeof.asizeof(lc)
---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
[<ipython-input-13-88b6425eddfd>](https://localhost:8080/#) in <module>()
      8 
      9 lc = lk.search_lightcurve("TOI 588", author="SPOC").download_all().stitch().remove_nans()
---> 10 asizeof.asizeof(lc)

30 frames
[/usr/local/lib/python3.7/dist-packages/pympler/asizeof.py](https://localhost:8080/#) in reset(self, base, item, leng, refs, both, kind, type, vari)
   1190         '''
   1191         if base < 0:
-> 1192             raise ValueError('invalid option: %s=%r' % ('base', base))
   1193         else:
   1194             self.base = base

ValueError: invalid option: base=-391848

About this issue

  • Original URL
  • State: open
  • Created 4 years ago
  • Comments: 17 (10 by maintainers)

Commits related to this issue

Most upvoted comments

A patch for asizeof.py has been submitted. Until that patch is merged into Pympler, here is a link to asizeof.py version 24.08.21.

Will investigate.

CORRECTION. Thank you! I’m able to duplicate the problem with Python 3.10.5 (on macOS and Apple Si), but only with asizeof version 21.08.09 or older. More recent versions do not exhibit the issue, however those may not have been pulled into pympler yet.

Here is a link to asizeof version 22.06.30 for your consideration. Instead of …

from pympler import asizeof
...

use …

import asizeof220630 as asizeof
...