• 全国 [切换]
  • 二维码
    低淘展会

    手机WAP版

    手机也能找商机,信息同步6大终端平台!

    微信小程序

    微信公众号

    当前位置: 首页 » 行业新闻 » 热点新闻 » 正文

    《CPython Internals》阅读笔记:p177-p220

    放大字体  缩小字体 发布日期:2025-01-17 03:42:38   浏览次数:5  发布人:6fdd****  IP:124.223.189***  评论:0
    导读

    《CPython Internals》学习第 11天,p177-p220 总结,总计 44 页。 一、技术总结 1.memory allocation in C (1)static memeory allocation Memory requirements are calculated at compile time and allocated by the executable when it

    《CPython Internals》学习第 11天,p177-p220 总结,总计 44 页。

    一、技术总结

    1.memory allocation in C

    (1)static memeory allocation

    Memory requirements are calculated at compile time and allocated by the executable when it starts.

    (2)automatic memeory allocation

    Memory requirements for a scope are allocated within the call stack when a frame is entered and are freed once the frame is terminated.

    (3)dynamic memeory allocation

    Memory can be requested and allocated dynamically at runtime by calls to the memory allocation API。

    上面这几个定义摘自第 178 页。我不得不再次吐槽:既然是分类,那么分类的依据是什么?很遗憾,作者没有说。介于此,补充一个GNU的文档说明,个人觉得GNU的说明更清楚:

    The C language supports two kinds of memory allocation through the variables in C programs:

    Static allocation is what happens when you declare a static or global variable. Each static or global variable defines one block of space, of a fixed size. The space is allocated once, when your program is started (part of the exec operation), and is never freed.

    Automatic allocation happens when you declare an automatic variable, such as a function argument or a local variable. The space for an automatic variable is allocated when the compound statement containing the declaration is entered, and is freed when that compound statement is exited.In GNU C, the size of the automatic storage can be an expression that varies. In other C implementations, it must be a constant.

    A third important kind of memory allocation, dynamic allocation, is not supported by C variables but is available via GNU C Library functions.

    Dynamic memory allocation is a technique in which programs determine as they are running where to store some information. You need dynamic allocation when the amount of memory you need, or how long you continue to need it, depends on factors that are not known before the program runs.

    For example, you may need a block to store a line read from an input file; since there is no limit to how long a line can be, you must allocate the memory dynamically and make it dynamically larger as you read more of the line.

    从GNU的文档中我们不难看出:首先根据是否需要手动可

    二、英语总结(生词:0)

    无。

    关于英语的注解同步更新汇总到 https://github.com/codists/English-In-CS-Books 仓库。

    三、其它

    今天没有什么想说的。

    四、参考资料

    1. 编程

    (1) Anthony Shaw,《CPython Internals》:https://book.douban.com/subject/35405785/

    2. 英语

    (1) Etymology Dictionary:https://www.etymonline.com

    (2) Cambridge Dictionary:https://dictionary.cambridge.org

    欢迎搜索及关注:编程人(a_codists)

     
    (文/匿名(若涉版权问题请联系我们核实发布者) / 非法信息举报 / 删稿)
    打赏
    免责声明
    • 
    本文为昵称为 6fdd**** 发布的作品,本文仅代表发布者个人观点,本站未对其内容进行核实,请读者仅做参考,如若文中涉及有违公德、触犯法律的内容,一经发现,立即删除,发布者需自行承担相应责任。涉及到版权或其他问题,请及时联系我们154208694@qq.com删除,我们积极做(权利人与发布者之间的调停者)中立处理。郑重说明:不 违规举报 视为放弃权利,本站不承担任何责任!
    有个别老鼠屎以营利为目的遇到侵权情况但不联系本站或自己发布违规信息然后直接向本站索取高额赔偿等情况,本站一概以诈骗报警处理,曾经有1例诈骗分子已经绳之以法,本站本着公平公正的原则,若遇 违规举报 我们100%在3个工作日内处理!
    0相关评论
     

    (c)2008-现在 ditao.net All Rights Reserved.