# mypy: ignore-errors
"""
This is a stripped-down of asizeof.py from the pympler module. It's vendored
because pympler is unmaintained, while having a critical vulnerability.
Differences from the original asizeof module:
- Removed code for running as __main__
- Removed `adict`
- `__all__` only includes `asizeof`
The *original* original copyright, license and disclaimer are at the end of this
file, exactly as they appeared in the pympler code. pympler itself is under the
Apache license, which appears in the project root.
The original module docstring that appears in pympler follows; note that some of
it no longer pertains here, but it's preserved to document implementation
details.
"""
"""
**Public Functions** [#unsafe]_
Function **asizesof** returns a tuple containing the (approximate)
size in bytes for each given Python object separately.
Function **asized** returns for each object an instance of class
**Asized** containing all the size information of the object and
a tuple with the referents [#refs]_.
Functions **basicsize** and **itemsize** return the *basic-*
respectively *itemsize* of the given object, both in bytes. For
objects as ``array.array``, ``numpy.array``, ``numpy.ndarray``,
etc. where the item size varies depending on the instance-specific
data type, function **itemsize** returns that item size.
Function **flatsize** returns the *flat size* of a Python object
in bytes defined as the *basic size* plus the *item size* times
the *length* of the given object.
Function **leng** returns the *length* of an object, like standard
function ``len`` but extended for several types. E.g. the **leng**
of a multi-precision int (formerly long) is the number of ``digits``
[#digit]_. The length of most *mutable* sequence objects includes
an estimate of the over-allocation and therefore, the **leng** value
may differ from the standard ``len`` result. For objects like
``array.array``, ``numpy.array``, ``numpy.ndarray``, etc. function
**leng** returns the proper number of items.
Function **refs** returns (a generator for) the referents [#refs]_
of the given object.
**Public Classes** [#unsafe]_
Class **Asizer** may be used to accumulate the results of several
**asizeof** or **asizesof** calls. After creating an **Asizer**
instance, use methods **asizeof** and **asizesof** as needed to
size any number of additional objects.
Call methods **exclude_refs** and/or **exclude_types** to exclude
references to respectively instances or types of certain objects.
Use one of the **print\\_...** methods to report the statistics.
An instance of class **Asized** is returned for each object sized
by the **asized** function or method.
**Duplicate Objects**
Any duplicate, given objects are sized only once and the size
is included in the accumulated total only once. But functions
**asizesof** and **asized** will return a size value respectively
an **Asized** instance for each given object, including duplicates.
**Definitions** [#arb]_
The *length* of an objects like ``dict``, ``list``, ``set``,
``str``, ``tuple``, etc. is defined as the number of items held
in or allocated by the object. Held items are *references* to
other objects, called the *referents*.
The *size* of an object is defined as the sum of the *flat size*
of the object plus the sizes of any referents [#refs]_. Referents
are visited recursively up to the specified detail level. However,
the size of objects referenced multiple times is included only once
in the total *size*.
The *flat size* of an object is defined as the *basic size* of the
object plus the *item size* times the number of allocated *items*,
*references* to referents. The *flat size* does include the size
for the *references* to the referents, but not the size of the
referents themselves.
The *flat size* returned by function *flatsize* equals the result
of function *asizeof* with options *code=True*, *ignored=False*,
*limit=0* and option *align* set to the same value.
The accurate *flat size* for an object is obtained from function
``sys.getsizeof()`` where available. Otherwise, the *length* and
*size* of sequence objects as ``dicts``, ``lists``, ``sets``, etc.
is based on an estimate for the number of allocated items. As a
result, the reported *length* and *size* may differ substantially
from the actual *length* and *size*.
The *basic* and *item size* are obtained from the ``__basicsize__``
respectively ``__itemsize__`` attributes of the (type of the)
object. Where necessary (e.g. sequence objects), a zero
``__itemsize__`` is replaced by the size of a corresponding C type.
The overhead for Python's garbage collector (GC) is included in
the *basic size* of (GC managed) objects as well as the space
needed for ``refcounts`` (used only in certain Python builds).
Optionally, size values can be aligned to any power-of-2 multiple.
**Size of (byte)code**
The *(byte)code size* of objects like classes, functions, methods,
modules, etc. can be included by setting option *code=True*.
Iterators are handled like sequences: iterated object(s) are sized
like *referents* [#refs]_, but only up to the specified level or
recursion *limit* (and only if function ``gc.get_referents()``
returns the referent object of iterators).
Generators are sized as *(byte)code* only, but the objects are
never generated and never sized.
**New-style Classes**
All ``class``, instance and ``type`` objects are handled uniformly
such that instance objects are distinguished from class objects.
Class and type objects are represented as ``<class .... def>``
respectively ``<type ... def>`` where the ``... def`` suffix marks
the *definition object*. Instances of classes are shown as
``<class module.name>`` without the ``... def`` suffix.
**Ignored Objects**
To avoid excessive sizes, several object types are ignored [#arb]_
by default, e.g. built-in functions, built-in types and classes
[#bi]_, function globals and module referents. However, any
instances thereof and module objects will be sized when passed as
given objects. Ignored object types are included unless option
*ignored* is set accordingly.
In addition, many ``__...__`` attributes of callable objects are
ignored [#arb]_, except crucial ones, e.g. class attributes ``__dict__``,
``__doc__``, ``__name__`` and ``__slots__``. For more details, see
the type-specific ``_..._refs()`` and ``_len_...()`` functions below.
.. rubric:: Footnotes
.. [#unsafe] The functions and classes in this module are not thread-safe.
.. [#refs] The *referents* of an object are the objects referenced *by*
that object. For example, the *referents* of a ``list`` are the
objects held in the ``list``, the *referents* of a ``dict`` are
the key and value objects in the ``dict``, etc.
.. [#arb] These definitions and other assumptions are rather arbitrary
and may need corrections or adjustments.
.. [#digit] The C ``sizeof(digit)`` in bytes can be obtained from the
``int.__itemsize__`` attribute or since Python 3.1+ also from
attribute ``sys.int_info.sizeof_digit``. Function **leng**
determines the number of ``digits`` of a multi-precision int.
.. [#bi] All ``type``s and ``class``es in modules named in private set
``_ignored_modules`` are ignored like other, standard built-ins.
"""
import sys
import types as Types
import warnings
import weakref as Weakref
from inspect import isbuiltin, isclass, iscode, isframe, isfunction, ismethod, ismodule
from math import log
from os import curdir, linesep
from struct import calcsize
__all__ = ["asizeof"]
__version__ = "22.06.30"
_NN = ""
_Not_vari = _NN # non-variable item size
# Any classes and types in modules named in set _ignored_modules
# are ignored by
没有合适的资源?快使用搜索试试~ 我知道了~
可视化的Python框架:streamlit
共2000个文件
py:678个
png:421个
tsx:348个
需积分: 3 2 下载量 90 浏览量
2024-03-09
20:02:25
上传
评论
收藏 69.63MB ZIP 举报
温馨提示
主要语言:Python 项目分类:[前端] [工具] [应用软件] 项目标签:[可视化工具] [编程工具] 推荐理由:一个Python框架,可以快速将数据转化为交互式可视化页面。它允许用户轻松地将数据制作成图表,并提供免费的共享服务平台,帮助用户将项目上线,实现数据的共享和讨论。
资源推荐
资源详情
资源评论
收起资源包目录
可视化的Python框架:streamlit (2000个子文件)
.isort.cfg 74B
streamlit.cmd 676B
CODEOWNERS 968B
.coveragerc 72B
vega-embed.css 3KB
vega-tooltip.css 1KB
.dockerignore 109B
.dockerignore 33B
.editorconfig 492B
open-iconic.eot 28KB
fireworks.gif 100KB
icon_running.gif 3KB
encrypted_credentials_snowflake.json.gpg 246B
hostframe.html 6KB
index.html 2KB
iframed_streamlit.html 2KB
favicon.ico 1KB
favicon.ico 1KB
MANIFEST.in 100B
mypy.ini 1KB
pytest.ini 277B
bokeh-mathjax-2.4.3.esm.min.js 1.68MB
bokeh.esm.js 782KB
bokeh-tables-2.4.3.esm.min.js 285KB
bokeh-widgets-2.4.3.esm.min.js 246KB
bokeh-gl-2.4.3.esm.min.js 187KB
bokeh-api-2.4.3.esm.min.js 86KB
st_file_uploader.spec.js 15KB
iframerResizer.min.js 14KB
commands.js 9KB
st_tooltips.spec.js 8KB
.eslintrc.js 6KB
st_slider.spec.js 5KB
hostframe.spec.js 5KB
st_select_slider.spec.js 5KB
create.js 5KB
websocket_reconnects.spec.js 5KB
craco.config.js 4KB
st_image.spec.js 4KB
st_markdown.spec.js 4KB
st_image_svg_sizing.spec.js 4KB
typography.spec.js 4KB
st_hello.spec.js 3KB
st_tooltips_2.spec.js 3KB
st_form_column_association.spec.js 3KB
st_columns.spec.js 3KB
st_arrow_unevaluated_snowpark_dataframe.spec.js 3KB
iframe_resizer.spec.js 3KB
st_arrow_unevaluated_pyspark_dataframe.spec.js 3KB
st_download_button.spec.js 3KB
st_set_page_config.spec.js 3KB
jest.config.js 3KB
st_session_state.spec.js 3KB
st_image_replay.spec.js 2KB
st_map.spec.js 2KB
st_camera_input.spec.js 2KB
st_heading.spec.js 2KB
st_arrow_empty_charts.spec.js 2KB
st_caption.spec.js 2KB
st_media_replay.spec.js 2KB
st_sidebar.spec.js 2KB
st_tabs.spec.js 2KB
st_disabled.spec.js 2KB
fileTransform.js 2KB
st_arrow_table_styling.spec.js 2KB
index.js 2KB
staticfiles_app.spec.js 2KB
st_arrow_empty_tables.spec.js 2KB
st_title.spec.js 2KB
st_arrow_scatter_chart.spec.js 2KB
redisplayed_widgets.spec.js 2KB
widget_state_heavy_usage.spec.js 2KB
st_experimental_get_query_params.spec.js 2KB
index.js 2KB
st_disconnect.spec.js 1KB
st_image_replay_old_image.spec.js 1KB
st_reuse_label.spec.js 1KB
session_state_frontend_sync.spec.js 1KB
st_arrow_table_sizes.spec.js 1KB
st_subheader.spec.js 1KB
st_columns_layout.spec.js 1KB
st_arrow_line_chart.spec.js 1KB
st_arrow_area_chart.spec.js 1KB
st_arrow_bar_chart.spec.js 1KB
st_json.spec.js 1KB
jsdom-polyfill-env.js 1KB
st_magic.spec.js 1KB
st_exception.spec.js 1KB
st_pydeck_geo_layers.spec.js 1KB
st_experimental_set_query_params.spec.js 1KB
setupTestEnv.js 1KB
st_arrow_new_features.spec.js 1KB
st_arrow_table.spec.js 1KB
st_balloons.spec.js 1KB
st_in_cache_warning.spec.js 1KB
cssTransform.js 1KB
st_snow.spec.js 1KB
st_message_deduping.spec.js 1KB
st_nested_columns_4.spec.js 1KB
st_nested_columns_1.spec.js 1KB
共 2000 条
- 1
- 2
- 3
- 4
- 5
- 6
- 20
资源评论
全栈海哥
- 粉丝: 1624
- 资源: 98
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功