Title: Python's Sampling Profiler: Low-Overhead Profiling With profiling.sampling – Real Python
Open Graph Title: Python's Sampling Profiler: Low-Overhead Profiling With profiling.sampling – Real Python
Description: Explore Python 3.15's new sampling profiler and learn low-overhead profiling of scripts, threads, and live production processes.
Open Graph Description: Explore Python 3.15's new sampling profiler and learn low-overhead profiling of scripts, threads, and live production processes.
Mail addresses
?subject=Python article for you&body=Python's Sampling Profiler: Low-Overhead Profiling With profiling.sampling on Real Python
https://realpython.com/python315-sampling-profiler/
Opengraph URL: https://realpython.com/python315-sampling-profiler/
X: @realpython
Domain: realpython.com
{
"@context": "http://schema.org",
"@type": "Article",
"headline": "Python's Sampling Profiler: Low-Overhead Profiling With profiling.sampling",
"image": {
"@type": "ImageObject",
"url": "https://files.realpython.com/media/Python-3.15-Preview-New-Profiling-Module_Watermarked.27cdafb337e4.jpg",
"width": 1920,
"height": 1080
},
"mainEntityOfPage": {
"@type": "WebPage",
"@id": "https://realpython.com/python315-sampling-profiler/",
"lastReviewed": "2026-10-12",
"author": {
"@type": "Person",
"name": "Bartosz Zaczy\u0144ski",
"image": "https://realpython.com/cdn-cgi/image/width=1694,height=1694,fit=crop,gravity=auto,format=auto/https://files.realpython.com/media/coders_lab_2109368.259b1599fbee.jpg",
"url": "https://realpython.com/team/bzaczynski/",
"affiliation": {
"@type": "Organization",
"@id": "https://realpython.com/#organization",
"name": "Real Python",
"url": "https://realpython.com",
"logo": "https://realpython.com/static/real-python-logo-square-512.157ae6bf64ed.png"
}
},
"reviewedBy": [
{
"@type": "Person",
"name": "Aldren Santos",
"image": "https://realpython.com/cdn-cgi/image/width=500,height=500,fit=crop,gravity=auto,format=auto/https://files.realpython.com/media/Aldren_Santos_Real_Python.6b0861d8b841.png",
"url": "https://realpython.com/team/asantos/",
"affiliation": {
"@type": "Organization",
"@id": "https://realpython.com/#organization",
"name": "Real Python",
"url": "https://realpython.com",
"logo": "https://realpython.com/static/real-python-logo-square-512.157ae6bf64ed.png"
}
},
{
"@type": "Person",
"name": "Brenda Weleschuk",
"image": "https://realpython.com/cdn-cgi/image/width=320,height=320,fit=crop,gravity=auto,format=auto/https://files.realpython.com/media/IMG_3324_1.50b309355fc1.jpg",
"url": "https://realpython.com/team/bweleschuk/",
"affiliation": {
"@type": "Organization",
"@id": "https://realpython.com/#organization",
"name": "Real Python",
"url": "https://realpython.com",
"logo": "https://realpython.com/static/real-python-logo-square-512.157ae6bf64ed.png"
}
},
{
"@type": "Person",
"name": "Leodanis Pozo Ramos",
"image": "https://realpython.com/cdn-cgi/image/width=862,height=862,fit=crop,gravity=auto,format=auto/https://files.realpython.com/media/Perfil_final1.9f896bc212f6.jpg",
"url": "https://realpython.com/team/lpozoramos/",
"affiliation": {
"@type": "Organization",
"@id": "https://realpython.com/#organization",
"name": "Real Python",
"url": "https://realpython.com",
"logo": "https://realpython.com/static/real-python-logo-square-512.157ae6bf64ed.png"
}
}
]
},
"datePublished": "2026-08-26T14:00:00+00:00",
"dateModified": "2026-10-12T08:15:34.434285+00:00",
"publisher": {
"@type": "Organization",
"@id": "https://realpython.com/#organization",
"name": "Real Python",
"url": "https://realpython.com",
"logo": {
"@type": "ImageObject",
"url": "https://realpython.com/static/real-python-logo-square-512.157ae6bf64ed.png",
"width": 512,
"height": 512
},
"description": "Real Python is a leading provider of online Python education and one of the largest language-specific online communities for software developers. It publishes high-quality learning resources, such as tutorials, books, and courses to an audience of millions of developers, data scientists, and machine learning engineers each month.",
"slogan": "Become a Python Expert",
"email": "info@realpython.com",
"sameAs": [
"https://github.com/realpython",
"https://www.youtube.com/realpython",
"https://twitter.com/realpython",
"https://x.com/realpython",
"https://www.linkedin.com/company/realpython-com/",
"https://www.facebook.com/learnrealpython",
"https://www.instagram.com/realpython",
"https://www.tiktok.com/@realpython.com"
]
},
"author": {
"@type": "Person",
"name": "Bartosz Zaczy\u0144ski",
"image": "https://realpython.com/cdn-cgi/image/width=1694,height=1694,fit=crop,gravity=auto,format=auto/https://files.realpython.com/media/coders_lab_2109368.259b1599fbee.jpg",
"url": "https://realpython.com/team/bzaczynski/",
"affiliation": {
"@type": "Organization",
"@id": "https://realpython.com/#organization",
"name": "Real Python",
"url": "https://realpython.com",
"logo": "https://realpython.com/static/real-python-logo-square-512.157ae6bf64ed.png"
}
},
"description": "Explore Python 3.15's new sampling profiler and learn low-overhead profiling of scripts, threads, and live production processes.",
"hasPart": {
"@type": "FAQPage",
"mainEntity": [
{
"@type": "Question",
"name": "What is the new sampling profiler in Python 3.15?",
"acceptedAnswer": {
"@type": "Answer",
"text": "\u003cp\u003eIt\u0026rsquo;s a statistical profiler in the standard library\u0026rsquo;s new \u003ccode\u003eprofiling.sampling\u003c/code\u003e module, code-named Tachyon. It periodically snapshots a process\u0026rsquo;s call stack from the outside\u0026mdash;a thousand times per second by default\u0026mdash;so the target keeps running at its normal speed.\u003c/p\u003e"
}
},
{
"@type": "Question",
"name": "Is cProfile deprecated in Python 3.15?",
"acceptedAnswer": {
"@type": "Answer",
"text": "\u003cp\u003eNo. Only the pure-Python \u003ccode\u003eprofile\u003c/code\u003e module is deprecated, with removal planned for Python 3.17. The \u003ca href=\"/ref/stdlib/cprofile/\" class=\"ref-link\"\u003e\u003ccode\u003ecProfile\u003c/code\u003e\u003c/a\u003e module remains available as a backward-compatible alias for the relocated \u003ccode\u003eprofiling.tracing\u003c/code\u003e module.\u003c/p\u003e"
}
},
{
"@type": "Question",
"name": "Can I profile a running production process without restarting it?",
"acceptedAnswer": {
"@type": "Answer",
"text": "\u003cp\u003eYes. The \u003ccode\u003eattach\u003c/code\u003e subcommand samples any live Python 3.15 process by its process ID without restarting or instrumenting it. You need debugger-level privileges, such as \u003ccode\u003esudo\u003c/code\u003e on Linux or macOS, and the profiler must run the same Python version as the target.\u003c/p\u003e"
}
},
{
"@type": "Question",
"name": "How is profiling.sampling different from py-spy?",
"acceptedAnswer": {
"@type": "Answer",
"text": "\u003cp\u003eBoth sample a target process from the outside, and \u003ca href=\"/ref/tools/py-spy/\" class=\"ref-link\"\u003epy\u0026#45;spy\u003c/a\u003e pioneered this approach for Python. The standard-library profiler requires no installation, understands 3.15\u0026rsquo;s interpreter internals, including async task stacks and specialized \u003ca href=\"/ref/glossary/bytecode/\" class=\"ref-link\"\u003ebytecode\u003c/a\u003e instructions, and adds a live TUI plus flame-graph, heatmap, and Firefox Profiler outputs. However, py-spy supports attaching to a wider range of Python versions.\u003c/p\u003e"
}
},
{
"@type": "Question",
"name": "Does the sampling profiler work with threads and async code?",
"acceptedAnswer": {
"@type": "Answer",
"text": "\u003cp\u003eYes. Pass \u003ccode\u003e-a\u003c/code\u003e to sample all threads instead of just the main one, and \u003ccode\u003e--async-aware\u003c/code\u003e to reconstruct \u003ca href=\"/ref/stdlib/asyncio/\" class=\"ref-link\"\u003easyncio\u003c/a\u003e task stacks, optionally with \u003ccode\u003e--async-mode all\u003c/code\u003e to include tasks suspended at \u003ccode\u003eawait\u003c/code\u003e expressions. Named tasks appear under their names in the report.\u003c/p\u003e"
}
}
]
}
}
| author | Real Python |
| theme-color | #18354c |
| color-scheme | light dark |
| twitter:card | summary_large_image |
| twitter:image | https://files.realpython.com/media/Python-3.15-Preview-New-Profiling-Module_Watermarked.27cdafb337e4.jpg |
| og:image | https://files.realpython.com/media/Python-3.15-Preview-New-Profiling-Module_Watermarked.27cdafb337e4.jpg |
| twitter:creator | @realpython |
| og:type | article |
| og:site_name | Real Python |
| apple-mobile-web-app-title | Real Python |
Links:
Viewport: width=device-width, initial-scale=1, shrink-to-fit=no, viewport-fit=cover
Robots: max-image-preview:large