find-cpython-usage
Find all CPython internal headers and structs used in the codebase, particularly for profiling functionality. Use this when adding support for a new Python version to identify what CPython internals we depend on.
Install
mkdir -p .claude/skills/find-cpython-usage && curl -L -o skill.zip "https://mcp.directory/api/skills/download/7885" && unzip -o skill.zip -d .claude/skills/find-cpython-usage && rm skill.zipInstalls to .claude/skills/find-cpython-usage
About this skill
Find CPython Internal Usage Skill
This skill helps identify all CPython internal headers and structures used in the codebase, which is essential when adding support for new Python versions.
When to Use This Skill
Use this skill when:
- Adding support for a new Python version
- Investigating CPython API dependencies
- Understanding what internal APIs the profiler uses
- Preparing to compare CPython versions
Key Principles
- Focus on internal headers - These are most likely to change between versions
- Check all native extensions - CPython internals are used in profiling, AppSec, and internal modules
- Look for struct field access - Direct field access is version-sensitive
- Document findings - Keep track of what you find for comparison
How This Skill Works
Step 1: Find CPython Header Includes
Search for CPython header includes across all C/C++/Cython files:
# Find all CPython internal header includes
grep -r "include.*internal/pycore" ddtrace/ --include="*.c" --include="*.cpp" --include="*.h" --include="*.hpp" --include="*.pyx"
# Find all CPython cpython header includes
grep -r "include.*cpython" ddtrace/ --include="*.c" --include="*.cpp" --include="*.h" --include="*.hpp" --include="*.pyx"
# Find all Python.h includes (indicates CPython API usage)
grep -r "#include.*Python\.h" ddtrace/ --include="*.c" --include="*.cpp" --include="*.h" --include="*.hpp" --include="*.pyx"
# Find frameobject.h includes (common CPython API)
grep -r "#include.*frameobject\.h" ddtrace/ --include="*.c" --include="*.cpp" --include="*.h" --include="*.hpp" --include="*.pyx"
# Find PyO3 FFI usage in Rust (Rust extensions may use CPython internals)
grep -r "pyo3_ffi::\|pyo3::ffi::" src/native/ --include="*.rs" || true
Note: These patterns search across all native extension files (.c, .cpp, .h, .hpp, .pyx, .rs)
regardless of their location in the codebase. Check setup.py to see which extensions are built.
Rust extensions use PyO3 which may access CPython internals through the pyo3_ffi module.
Step 2: Find Struct Field Access
Search for direct struct field access and struct definitions across all native files:
# Find struct field accesses (arrow operator)
grep -r "->f_\|->[a-z_]*\." ddtrace/ --include="*.c" --include="*.cpp" --include="*.h" --include="*.hpp"
# Find struct definitions
grep -r "struct.*Py" ddtrace/ --include="*.c" --include="*.cpp" --include="*.h" --include="*.hpp"
# Find common CPython struct usage
grep -r "PyFrameObject\|PyThreadState\|_PyInterpreterFrame" ddtrace/ --include="*.c" --include="*.cpp" --include="*.h" --include="*.hpp" --include="*.pyx"
grep -r "PyFrameObject\|PyThreadState\|PyInterpreterState" src/native/ --include="*.rs" || true
# Find PyCodeObject usage
grep -r "PyCodeObject" ddtrace/ --include="*.c" --include="*.cpp" --include="*.h" --include="*.hpp" --include="*.pyx"
grep -r "PyCodeObject" src/native/ --include="*.rs" || true
Look for patterns like:
- Frame structure access (
PyFrameObject,_PyInterpreterFrame) - Thread state access (
PyThreadState) - Code object access (
PyCodeObject) - Generator/coroutine structures
- Asyncio task structures
Step 3: Identify Common Structures
Common CPython structures we typically access:
Frame structures:
PyFrameObject/struct _frame_PyInterpreterFrame
State structures:
PyThreadStatePyInterpreterState_PyRuntimeState
Code structures:
PyCodeObject
Generator structures:
PyGenObjectPyAsyncGenASend
Asyncio structures:
FutureObjTaskObj
Step 4: Document Findings
Create a list of:
- All headers that are included
- All structs that are accessed
- All struct fields that are used directly
This will be used in the next step to compare against the new Python version.
Native Extensions Using CPython APIs
To find all native extensions that may use CPython APIs, check setup.py:
# View all native extensions defined in setup.py
grep -A 5 "Extension\|CMakeExtension\|Cython.Distutils.Extension\|RustExtension" setup.py
The setup.py file defines all native extensions (C, C++, CMake, Cython, and Rust) that
are built for the project. Not all extensions use CPython internals - focus on those
that access frame objects, thread state, or internal structures when searching for
CPython API usage.
Note: Rust extensions use PyO3 bindings which may access CPython internals through
pyo3_ffi module. Search Rust source files (.rs) for CPython API usage as well.
Common Headers to Look For
The grep commands above will identify which CPython headers are actually used in the codebase. Common patterns include:
Public Headers:
- Headers matching
*.hinInclude/directory (e.g.,frameobject.h,unicodeobject.h) - Headers in
Include/cpython/directory (e.g.,cpython/genobject.h)
Internal Headers (require Py_BUILD_CORE):
- Headers matching
internal/pycore*.hpattern - These are most likely to change between Python versions
Focus on headers that are actually found by the grep commands rather than maintaining a hardcoded list, as the headers used may change over time.
Output Format
After running this skill, you should have:
- A list of all CPython headers included in the codebase
- A list of all CPython structs accessed
- A list of struct fields accessed directly
- Files that use each header/struct
This information can then be used with the compare-cpython-versions skill to identify what changed.
Related
- compare-cpython-versions skill: Use findings from this skill to compare versions
More by DataDog
View all skills by DataDog →You might also like
flutter-development
aj-geddes
Build beautiful cross-platform mobile apps with Flutter and Dart. Covers widgets, state management with Provider/BLoC, navigation, API integration, and material design.
drawio-diagrams-enhanced
jgtolentino
Create professional draw.io (diagrams.net) diagrams in XML format (.drawio files) with integrated PMP/PMBOK methodologies, extensive visual asset libraries, and industry-standard professional templates. Use this skill when users ask to create flowcharts, swimlane diagrams, cross-functional flowcharts, org charts, network diagrams, UML diagrams, BPMN, project management diagrams (WBS, Gantt, PERT, RACI), risk matrices, stakeholder maps, or any other visual diagram in draw.io format. This skill includes access to custom shape libraries for icons, clipart, and professional symbols.
ui-ux-pro-max
nextlevelbuilder
"UI/UX design intelligence. 50 styles, 21 palettes, 50 font pairings, 20 charts, 8 stacks (React, Next.js, Vue, Svelte, SwiftUI, React Native, Flutter, Tailwind). Actions: plan, build, create, design, implement, review, fix, improve, optimize, enhance, refactor, check UI/UX code. Projects: website, landing page, dashboard, admin panel, e-commerce, SaaS, portfolio, blog, mobile app, .html, .tsx, .vue, .svelte. Elements: button, modal, navbar, sidebar, card, table, form, chart. Styles: glassmorphism, claymorphism, minimalism, brutalism, neumorphism, bento grid, dark mode, responsive, skeuomorphism, flat design. Topics: color palette, accessibility, animation, layout, typography, font pairing, spacing, hover, shadow, gradient."
godot
bfollington
This skill should be used when working on Godot Engine projects. It provides specialized knowledge of Godot's file formats (.gd, .tscn, .tres), architecture patterns (component-based, signal-driven, resource-based), common pitfalls, validation tools, code templates, and CLI workflows. The `godot` command is available for running the game, validating scripts, importing resources, and exporting builds. Use this skill for tasks involving Godot game development, debugging scene/resource files, implementing game systems, or creating new Godot components.
nano-banana-pro
garg-aayush
Generate and edit images using Google's Nano Banana Pro (Gemini 3 Pro Image) API. Use when the user asks to generate, create, edit, modify, change, alter, or update images. Also use when user references an existing image file and asks to modify it in any way (e.g., "modify this image", "change the background", "replace X with Y"). Supports both text-to-image generation and image-to-image editing with configurable resolution (1K default, 2K, or 4K for high resolution). DO NOT read the image file first - use this skill directly with the --input-image parameter.
fastapi-templates
wshobson
Create production-ready FastAPI projects with async patterns, dependency injection, and comprehensive error handling. Use when building new FastAPI applications or setting up backend API projects.
Related MCP Servers
Browse all serversSearch and discover MCP servers with the official MCP Registry — browse an up-to-date MCP server list to find MCP server
Find official MCP servers for Google Maps. Explore resources to build, integrate, and extend apps with Google directions
Explore official Google BigQuery MCP servers. Find resources and examples to build context-aware apps in Google's ecosys
Obsidian: fast search and analysis of Markdown notes across Obsidian vaults — find, filter, and analyze notes with an in
Boost AI coding agents with Ref Tools—efficient documentation access for faster, smarter code generation than GitHub Cop
Acemcp: semantic code search across codebases with incremental indexing. Find relevant snippets, file paths and line num
Stay ahead of the MCP ecosystem
Get weekly updates on new skills and servers.