V2EX = way to explore
V2EX 是一个关于分享和探索的地方
Sign Up Now
For Existing Member  Sign In
推荐学习书目
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
Sherlockhlt
V2EX  ›  Python

Python3的long实现问题

  •  
  •   Sherlockhlt · Mar 27, 2013 · 5443 views
    This topic created in 4791 days ago, the information mentioned may be changed or developed.
    两个问题,困惑了我好久:
    1. Python3中是不是把int都改成long,然后对外申称都是int了?
    2. Python3中是不是long都改成不缓存了?在longobject.c里面没有看到对象缓存(free list)的代码。
    4 replies    1970-01-01 08:00:00 +08:00
    timonwong
        1
    timonwong  
       Mar 27, 2013
    1. 嗯,统一为int,就是Python 2.x的long
    2. 有的:
    int
    _PyLong_Init(void)
    {
    #if NSMALLNEGINTS + NSMALLPOSINTS > 0 // 从这里开始分配
    ...... 一段代码
    #endif // 这里结束
    /* initialize int_info */
    Sherlockhlt
        2
    Sherlockhlt  
    OP
       Mar 27, 2013
    @timonwong
    这一段是存放小整数的,只存放[-5,257)
    在2.6.x中,大整数是用自由链表来缓存的,但是在3.0找了很久都找不到。。
    timonwong
        3
    timonwong  
       Mar 27, 2013
    @Sherlockhlt
    刚才理解错了,确实没有freelist了
    这里有相关的issue
    http://bugs.python.org/issue2013
    Sherlockhlt
        4
    Sherlockhlt  
    OP
       Mar 27, 2013
    @timonwong
    哦,原来他们觉得优化不够明显就删掉了。。3.0改动真多阿
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   2997 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 37ms · UTC 08:38 · PVG 16:38 · LAX 01:38 · JFK 04:38
    ♥ Do have faith in what you're doing.