推荐学习书目
Learn Python the Hard Way
Python Sites
PyPI - Python Package Index
http://diveintopython.org/toc/index.html
Pocoo
值得关注的项目
PyPy
Celery
Jinja2
Read the Docs
gevent
pyenv
virtualenv
Stackless Python
Beautiful Soup
结巴中文分词
Green Unicorn
Sentry
Shovel
Pyflakes
pytest
Python 编程
pep8 Checker
Styles
PEP 8
Google Python Style Guide
Code Style from The Hitchhiker's Guide
dbow
V2EX  ›  Python

分享一个程序,用于获取 python 内置对象的内存占用。

  •  
  •   dbow ·
    maliubiao · Jun 23, 2014 · 4648 views
    This topic created in 4369 days ago, the information mentioned may be changed or developed.
    python有gc平时不用关心内存, 大量处理数据的时候,要优化内存占用得知道这个
    代码: http://pastebin.ubuntu.com/7690309/
    输出示例:
    type basicsize itemsize mro
    <type 'NoneType'> 16 0 (<type 'NoneType'>, <type 'object'>)
    <type 'int'> 24 0 (<type 'int'>, <type 'object'>)
    <type 'long'> 24 4 (<type 'long'>, <type 'object'>)
    <type 'float'> 24 0 (<type 'float'>, <type 'object'>)
    <type 'bool'> 24 0 (<type 'bool'>, <type 'int'>, <type 'object'>)
    <type 'str'> 37 1 (<type 'str'>, <type 'basestring'>, <type 'object'>)
    <type 'unicode'> 48 0 (<type 'unicode'>, <type 'basestring'>, <type 'object'>)
    <type 'str'> 37 1 (<type 'str'>, <type 'basestring'>, <type 'object'>)
    <type 'complex'> 32 0 (<type 'complex'>, <type 'object'>)
    <type 'dict'> 248 0 (<type 'dict'>, <type 'object'>)
    <type 'tuple'> 24 8 (<type 'tuple'>, <type 'object'>)
    <type 'list'> 40 0 (<type 'list'>, <type 'object'>)
    <type 'set'> 200 0 (<type 'set'>, <type 'object'>)
    <type 'frozenset'> 200 0 (<type 'frozenset'>, <type 'object'>)
    ......
    No Comments Yet
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   919 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 26ms · UTC 20:43 · PVG 04:43 · LAX 13:43 · JFK 16:43
    ♥ Do have faith in what you're doing.