Я пытаюсь запустить скрипт Python (2.7) с PyPy, но столкнулся со следующей ошибкой:
TypeError: sys.getsizeof() is not implemented on PyPy.
A memory profiler using this function is most likely to give results
inconsistent with reality on PyPy. It would be possible to have
sys.getsizeof() return a number (with enough work), but that may or
may not represent how much memory the object uses. It doesn't even
make really sense to ask how much *one* object uses, in isolation
with the rest of the system. For example, instances have maps,
which are often shared across many instances; in this case the maps
would probably be ignored by an implementation of sys.getsizeof(),
but their overhead is important in some cases if they are many
instances with unique maps. Conversely, equal strings may share
their internal string data even if they are different objects---or
empty containers may share parts of their internals as long as they
are empty. Even stranger, some lists create objects as you read
them; if you try to estimate the size in memory of range(10**6) as
the sum of all items' size, that operation will by itself create one
million integer objects that never existed in the first place.
Теперь мне действительно нужно проверить размер одного вложенного словаря во время выполнения программы, есть ли альтернатива sys.getsizeof()
, которую я могу использовать в PyPy? Если нет, как мне проверить размер вложенного объекта в PyPy?
sys.getsizeof
не был бы подходящим инструментом для этого даже под CPython. Он не учитывает размеры других объектов, на которые объект содержит ссылки, таких как ключи и значения dict. - person user2357112 supports Monica   schedule 02.03.2017sys.getsizeof()
, даже если стена текста объяснит еще более подробно, почему это не имеет смысла, с примерами. - person Armin Rigo   schedule 04.03.2017