All Projects → Meteorix → pysourcenote

Meteorix / pysourcenote

Licence: other
Python源码学习笔记

Programming Languages

C++
36643 projects - #6 most used programming language
c
50402 projects - #5 most used programming language
CMake
9771 projects

Projects that are alternatives of or similar to pysourcenote

Hotels server
酒店预订系统后台管理系统
Stars: ✭ 249 (+453.33%)
Mutual labels:  source-code
debug-react-source-code
搭建阅读React源码调试环境,支持所有React版本细分文件断点调试。当前最新React版本:18.1.0。 Create an environment for reading and debugging react source code, support debugging breakpoints subdivision files of all react versions. Latest version: 18.1.0.
Stars: ✭ 144 (+220%)
Mutual labels:  source-code
note-cli
Markdown Indexing and Pcre Regular Expression Compatible Full Text Searching for Advanced Note Takers.
Stars: ✭ 15 (-66.67%)
Mutual labels:  learning-notes
objc-runtime-CN
Objective-C Runtime Analysis (Objective-C运行时分析)
Stars: ✭ 28 (-37.78%)
Mutual labels:  source-code
references-for-dotnet-developers
Sites, blogs, cursos, redes sociais e projetos de referências para desenvolvedores .NET
Stars: ✭ 329 (+631.11%)
Mutual labels:  source-code
Freemium-Music-App-Src
⏩ Complete Source code of Freemium Music App
Stars: ✭ 31 (-31.11%)
Mutual labels:  source-code
Mercury
Mercury is a hacking tool used to collect information and use the information to further hurt the target
Stars: ✭ 236 (+424.44%)
Mutual labels:  source-code
Java-Interview-Programs
Core Java Projects with complete source code
Stars: ✭ 48 (+6.67%)
Mutual labels:  source-code
Some Pentesters SecurityResearchers RedTeamers
Some Pentesters, Security Researchers, Red Teamers which i learned from them a lot...
Stars: ✭ 60 (+33.33%)
Mutual labels:  source-code
CodeDepot
A search engine for programming source code and documentation
Stars: ✭ 18 (-60%)
Mutual labels:  source-code
get-source
Fetch source-mapped sources. Peek by file, line, column. Node & browsers. Sync & async.
Stars: ✭ 26 (-42.22%)
Mutual labels:  source-code
GpuZen2
Sample code for the article 'Real-Time Layered Materials Compositing Using Spatial Clustering Encoding'
Stars: ✭ 17 (-62.22%)
Mutual labels:  source-code
winprint
winprint 2.0 - Advanced source code and text file printing. The perfect tool for printing source code, web pages, reports generated by legacy systems, documentation, or any text or HTML file. It works interactively or from the command line making it great for single users or whole enterprises. Works great with Powershell.
Stars: ✭ 52 (+15.56%)
Mutual labels:  source-code
Cookie-Clicker-Source-Code
Cookie Clicker source code for... educational purposes...
Stars: ✭ 74 (+64.44%)
Mutual labels:  source-code
flutter-ninja
A gentle introduction to an flutter.
Stars: ✭ 204 (+353.33%)
Mutual labels:  learning-notes
Just React
「React技术揭秘」 一本自顶向下的React源码分析书
Stars: ✭ 3,897 (+8560%)
Mutual labels:  source-code
NeuralCodeTranslator
Neural Code Translator provides instructions, datasets, and a deep learning infrastructure (based on seq2seq) that aims at learning code transformations
Stars: ✭ 32 (-28.89%)
Mutual labels:  source-code
Spy-Quiz
Hacker Challenge 👾
Stars: ✭ 17 (-62.22%)
Mutual labels:  source-code
notes
CCIE routing and switching notes and references, with a general directory and specific topic directories.
Stars: ✭ 23 (-48.89%)
Mutual labels:  learning-notes
AI-SOCO
Official FIRE 2020 Authorship Identification of SOurce COde (AI-SOCO) task repository containing dataset, evaluation tools and baselines
Stars: ✭ 16 (-64.44%)
Mutual labels:  source-code

Python源码学习笔记

刘欣 2018.10.30

最近在学习Python源码,参考《Python源码剖析》这本书。记录此学习笔记,分章节不定期更新,欢迎提PR和Issue : )

Table of Contents

Python总体架构

image

Python源码结构

cpython
├── Include     Python提供的所有头文件(著名的Python.h)
├── Lib         Python自带的标准库,python写的
├── Modules     标准库,c写的
├── Parser      语法分析部分
├── Objects     所有的内建对象c实现
├── Python      Compiler和Runtime引擎部分,运行核心所在
├── Mac         Mac平台编译部分
├── PCBuild     Window平台编译部分
...  

学习环境

  • 采用python2.7最新github cpython代码
  • macbook 开发环境 gcc编译
  • vscode + lldb做debugger

编译python

参考源码/Mac/README,用gcc编译python

./configure
make

编译出来的是在主目录下的./python.exe,不用怀疑,是一个在mac下可以启动的二进制

➜  cpython git:(2.7) ✗ ./python.exe 
Python 2.7.15+ (heads/2.7:64ffee7, Oct 30 2018, 18:02:37) 
[GCC 4.2.1 Compatible Apple LLVM 10.0.0 (clang-1000.11.45.2)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> 

通过第一行输出的Oct 30 2018, 18:02:37看出来,就是我们刚刚编译好的python了

vscode调试

有两种方式通过lldb来调试python: attachlaunch

准备工作

  1. vscode安装cpp插件:vscode-cpptools
  2. 在vscode里打开python源码,新建Debug配置,可能需要新建.vscode目录保存配置文件。如图:

image

lldb attach 配置

运行编译的python.exe,launch.json配置文件如下,proceeId修改为python.exe的pid:

        {
            "type": "cppdbg",
            "name": "(lldb) attach",
            "program": "${workspaceFolder}/python.exe",
            "request": "attach",
            "processId": "3917",
            "MIMode": "lldb"
        },

lldb launch 配置

选择launch方式启动,vscode会启动terminal运行python.exe

    "configurations": [
        {
            "name": "(lldb) Launch",
            "type": "cppdbg",
            "request": "launch",
            "program": "${workspaceFolder}/python.exe",
            "args": [],
            "stopAtEntry": false,
            "cwd": "${workspaceFolder}",
            "environment": [],
            "externalConsole": true,
            "MIMode": "lldb"
        }
    ]

然后可以通过断点的方式很方便地查看调用栈,配合《源码剖析》看非常有帮助。

如下图,可以看出一个简单的 1+2 c栈真tm深啊

image

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].