当前位置: 首页 > article >正文

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

《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)


http://www.kler.cn/a/506052.html

相关文章:

  • 运行fastGPT 第四步 配置ONE API 添加模型
  • 基于 requests 依赖包的 Python 爬虫实战
  • 微信小程序订阅消息提醒-云函数
  • 全网首发:编译libssh,产生类似undefined reference to `EVP_aes_256_ctr@OPENSSL_1_1_0‘的大量错误
  • 【Vue3 入门到实战】3. ref 和 reactive区别和适用场景
  • C++并发编程之std::async的异常安全性
  • 初始C#.
  • V2X工具箱 - ADAS测试日志记录工具分享
  • 以太网实战AD采集上传上位机——FPGA学习笔记27
  • 《鸿蒙Next平台:决策树面对噪声数据的鲁棒性逆袭》
  • 《WebForms 数据库连接》
  • 电梯系统的UML文档03
  • 在JavaScript中生成和处理二维码
  • 使用 Charles 调试 Flutter 应用中的 Dio 网络请求
  • 7.User-Agent(用户代理)
  • 【数据分析实战】马来西亚吉隆坡景点评论分析:多维度游客体验与运营优化洞察
  • 第30章 汇编语言--- 性能优化技巧
  • STM32 FreeRTOS中断管理
  • 语音识别的预训练模型
  • 初始Java5
  • 49.字母异位词
  • 单芯片控制多个高性能伺服电机
  • 【Linux】多路转接select
  • PyTorch使用教程(1)—PyTorch简介
  • MongoDB 学习建模与设计思路--统计数据更新案例
  • Ubuntu本地部署网站