# [Sampling CPython with WindowsPerf](https://learn.arm.com/learning-paths/laptops-and-desktops/windowsperf_sampling_cpython/)

## In this learning path

- [Introduction](https://learn.arm.com/learning-paths/laptops-and-desktops/windowsperf_sampling_cpython/)
- [CPython Sampling Example Overview](https://learn.arm.com/learning-paths/laptops-and-desktops/windowsperf_sampling_cpython/windowsperf_sampling_cpython/)
- [WindowsPerf sample example](https://learn.arm.com/learning-paths/laptops-and-desktops/windowsperf_sampling_cpython/windowsperf_sampling_cpython_example_1/)
- [WindowsPerf record example](https://learn.arm.com/learning-paths/laptops-and-desktops/windowsperf_sampling_cpython/windowsperf_sampling_cpython_example_2/)
- [Next Steps](https://learn.arm.com/learning-paths/laptops-and-desktops/windowsperf_sampling_cpython/_next-steps/)

## About this Learning Path

| Skill level:          | Introductory        |
|-----------------------|---------------------|
| Reading time:         | 30 min              |
| Last updated:         | 12 Aug 2026         |

| Author:               | Przemyslaw Wirkus    |
|-----------------------|---------------------|
| Arm IP:               | [Cortex-A](https://support.arm.com/?tab=compute-ip&Product%20Type=Application%20Processors) |
| Tags:                 | Performance and Architecture, Windows, WindowsPerf, Python, perf |

## Who is this for?
This is an introductory topic for developers keen to understand sampling and who are new to the Arm architecture.

## What will you learn?
Upon completion of this Learning Path, you will be able to:
- Use WindowsPerf with native Windows on Arm workload
- Understand the basics of sampling
- Explore the WindowsPerf command line
- Build CPython from sources for Windows on Arm ARM64 target

## Prerequisites
Before starting, you will need the following:
- Windows on Arm desktop or development machine with [WindowsPerf installed](/install-guides/wperf/)
- Windows x86_64 desktop machine with [Visual Studio 2022 Community Edition](https://visualstudio.microsoft.com/vs/) installed.

## Summary
You’ll build a debug CPython for Windows on Arm, then use WindowsPerf to measure a Python workload. First, you’ll pin `python_d.exe` to one core, run counting and sampling, and locate hot runtime code. Then, you’ll also use `record` and `-c` to launch the interpreter with arguments, creating repeatable measurements that distinguish aggregate counts from sampled locations.

## Frequently asked questions

### What result should I expect from counting versus sampling?
Counting returns aggregate totals for the selected events across the run. Sampling reports event frequencies tied to locations in the CPython runtime image so you can see where activity is concentrated.

### Which CPU core should I pin `python_d.exe` to?
Any single core is acceptable. Choose one and use it consistently across runs. Pinning reduces variability and makes results easier to compare.

### How do I launch CPython with WindowsPerf without starting it first?
Use the `record` command to spawn the process and pin it with the `-c` option. Specify the target either with `--pe_file` or by appending the `python_d.exe` command at the end of the WindowsPerf invocation.

### How do I pass arguments to CPython when using the record command?
Place all application arguments after the WindowsPerf options. WindowsPerf forwards them verbatim to the spawned program.

### What should I look for after running the Googolplex calculation?
Expect a sustained workload that exercises integer computation in CPython. Sampling output should attribute activity to hot locations in the CPython runtime image. If you see only totals, you ran counting instead of sampling.
