Introducing JIT may change the way Python loops are processed. The fact that it can speed things up by up to 20% is appealing, but since it's still in the experimental stage, I feel that we should proceed with caution before adopting it in practice. #Python #Technology
A quick video explanation of this blog post!
This blog post is explained in an easy-to-understand video.
Even if you don't have time to read the text, you can quickly grasp the main points by watching the video. Please take a look!
If you found this video helpful, please follow our YouTube channel "The Path of an AI Creator" for daily AI news.
Subscribe here:
https://www.youtube.com/@AIDoshi
Jon and Lila share their unique perspectives in this conversation in English 👉 [Read the dialogue in English]
Speed up your code with Python's new native JIT compiler! A practical guide for engineers
👋 Python developers, welcome to a world where your code runs faster! Python 3.15's native JIT compiler is experimental, but it delivers speed improvements of up to 20% or more. We'll dig deep into how it works and explain how you can try it out right away.
Python is flexible and popular, but execution speed is often a bottleneck. With the advent of JIT compilers, this may change. As an engineer, I share the excitement of trying out new tools. In this article, I will delve into the exact internal structure of JIT and its implementation limitations.
🔰 Article level:⚙️ Technical
🎯 Recommended for:Software engineers, backend developers, and data scientists interested in optimizing Python performance. People who want to understand how JIT and compilers work and use them in the field.
Introduction to Python's new native JIT compiler
- Native JIT Overview
- Differences from traditional Python
- interactive digital showroom
📖 Table of Contents
Background and Issues
Python is known as an interpreted language, and while it offers great flexibility, it is slower than Java or C++ in terms of execution speed. Bottlenecks arise especially in loops and computationally intensive tasks. Engineers have tried to solve this by using external tools like Numba and Cython, but these add additional dependencies and compromise the portability of their code.
This is where the native JIT compiler in Python 3.15 comes in. It's built into the CPython core and can optimize code without external libraries. This allows developers to achieve faster performance in standard environments. However, because it's experimental, there are limitations that mean it may not be effective in all cases.
While traditional Python interpreters execute bytecode sequentially, JIT detects hotspots and compiles them to native code, reducing the overhead of repetitively executed parts. The challenge is that the overhead of JIT itself can be counterproductive for small scripts.
Technical and content explanation
The native JIT in Python 3.15 uses a "copy-and-patch" design, which copies pre-generated templates and applies patches to generate native code. This is a simple implementation that avoids the complex optimization passes of traditional JITs.
Internally, instead of using LLVM, we build our own compiler backend, which translates directly from bytecode to machine code and caches it, minimizing startup latency while improving runtime speed.

Next, we present a table comparing the conventional Python and the new JIT. Understanding this will help engineers determine the appropriate scenarios.
| Item | Traditional Python (Interpreted) | New Native JIT |
|---|---|---|
| Execution method | Bytecode interpretation | Hot code native compilation |
| speed improvement | Base line | Up to 20%+ (by benchmark) |
| Dependence | None | Python 3.15+, --enable-jit flag |
| constraints | Slow Loop | Compilation overhead, experimental |
| Optimization example | Requires external tools (e.g. Numba) | Native and auto-optimized |
As can be seen from this table, JIT is particularly effective for loops and repetitive calculations. Technically speaking, JIT is triggered based on the number of executions. Code blocks that exceed a threshold are subject to compilation. A limitation is that, due to the nature of dynamic typing, its effectiveness is reduced when type inference is insufficient.
In terms of implementation details, the Python VM invokes the JIT and stores the generated machine code in an inline cache. In comparison, it is lighter than a full JIT like PyPy and maintains CPython compatibility, allowing existing code to benefit without any changes.
Additionally, benchmarks show a 10-20% improvement in compute-intensive tasks, but little change in I/O-bound tasks, which engineers should take into consideration and use profiling tools to identify bottlenecks.
Impact and use cases
The impact of this JIT is felt across the entire Python ecosystem, and as an engineer, it's especially useful for data processing and machine learning workloads, such as scripts using Pandas or NumPy, where loops are sped up and processing times are reduced.
Use Case 1: Backend API development. Using Flask or Django servers, compute-intensive endpoints are faster, improving response times and resulting in increased scalability.
Example 2: Scientific computing. Enabling JIT on simulation code makes repetitive calculations more efficient, allowing researchers and engineers to complete tasks that previously took hours in a fraction of the time.
Example 3: Microservices. When using Python in a container environment, JIT reduces resource consumption and optimizes cloud costs. The technical impact could be that Python becomes a more competitive language.
In terms of social impact, the spread of Python will accelerate. It will be used as a speed-up tool in education and startups, promoting innovation. However, not all apps will see immediate results.
Action Guide
For engineers, here are some steps you can try right away. First, install Python 3.15. To enable JIT, set the PYTHON_JIT=1 environment variable or build with the --enable-jit flag.
Step 1: Create a benchmark code. Test it with a simple Fibonacci function.
Step 2: Profiling. Use cProfile to identify bottlenecks and measure the effectiveness of JIT.
Step 3: Apply to real projects. Apply JIT to existing code and log the speed difference. Note the constraints and optimize as needed.
What to do next: Read the official documentation, explore the source in the CPython repository on GitHub, and share your feedback on the community forum.
Future prospects and risks
The future looks bright. With the JIT becoming stable in Python 3.16 and beyond, there is potential for further optimizations. Combined with tail call optimization, this could result in a boost of over 15% on Windows. As an engineer, this will help make Python an enterprise-level performance language.
The risk is that, because it is experimental, bugs may occur. There have been reports of compilation failures on certain platforms. Also, there are cases where small scripts become slow due to JIT overhead. From a security perspective, there are concerns about vulnerabilities in the JIT-generated code, but there are no serious issues at present.
To be fair, the development team has been working on it for over 30 months and has continued to improve it, but it is still slower than the interpreter in some benchmarks. To avoid risk, test thoroughly before putting it into production.
My Feelings, Then and Now
Python's native JIT provides engineers with new speed-up options. Understanding how it works and using it appropriately will expand the possibilities of your code. Go beyond conventional limits and achieve efficient development. I hope this article will be useful for your projects.
💬 Have you tried Python's JIT and noticed any speed improvements? Share in the comments!
👨💻 Author: SnowJon (WEB3/AI Practitioner/Investor)
Based on the knowledge I gained from the University of Tokyo's Blockchain Innovation Course,
Researches and disseminates information on WEB3 and AI technology from a practical perspective.
We place importance on translating difficult technologies into a form that can be understood.
*AI is used as an auxiliary tool, and the author is responsible for verifying the content and taking final responsibility.
Reference links and information sources
- Get started with Python's new native JIT | InfoWorld (Original article)
- Python official website (Release notes and documentation)
- DEVCLASS: Python JIT Developer Comments (Technical insight)
- CPython GitHub repository (See source code)
- Medium: JIT Compiler Building Guide (Related Learning Resources)
