Where do I start if I want to learn about the CPython implementation?

http://effbot.org/pyfaq/where-do-i-start-if-i-want-to-learn-about-the-cpython-implementation.htm


 

Q. Anyone have any good advice to someone interested in learning about innards of the Python implementation?

A. There are only a handful of top level directories that are interesting:

  • Include - include files
  • Objects - all Python objects (listdictintfloat, functions, and many others)
  • Python - core interpreter and other support facilities
  • Lib - Python stdlib (Lib/test is the test suite)
  • Modules - C extension modules
  • Parser - simple parser/tokenizer

The last three probably aren’t interesting. However, if you are interested in the GC (or SRE) implementation, then you should look under Modules as gcmodule.c and _sre.c are there. So are a bunch of others.

Include isn’t particularly interesting. Objects isn’t too interesting either from the standpoint of learning about the interpreter. Although the object implementations may be interesting in their own right. Each object is in an unsurprising file named something like: listobject.c or intobject.c.

That leaves Python which is where the real innards are. If you are interested in the interpreter, thenPython/ceval.c is pretty much it. The compiler is primarly in Python/compile.c, but also see Python/ast.c(2.5 only) and Python/symtable.c. All the global builtin functions are in Python/bltinmodule.c. Import support is in Python/import.c. Most of the other files in Python are small and/or platform specific. They probably aren’t as interesting in general.

(Based on a comp.lang.python post by Neal Norwitz)

CATEGORY: general

CATEGORY: cpython

转载于:https://www.cnblogs.com/threef/p/3269795.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值