The Wayback Machine - https://web.archive.org/web/20240902124145/https://www.geeksforgeeks.org/python-313-releases-enhanced-repl-for-developers/
Open In App

Python 3.13 Releases | Enhanced REPL for Developers

Last Updated : 28 Aug, 2024
Comments
Improve
Suggest changes
Like Article
Like
Save
Share
Report
News Follow

Python 3.13 is set to be the latest stable release of the Python programming language, bringing a bunch of exciting changes and enhancements that are sure to impact developers significantly. This release includes improvements to the language itself, its implementation, and the standard library. Among the most notable updates are the introduction of a new interactive interpreter also referred to as REPL, experimental support for running Python in a free-threaded mode, and the inclusion of a Just-In-Time (JIT) compiler.

In this article, we will explore the new features and improvements in Python 3.13 an exciting upgrade for developers. Let’s take a closer look at these key changes.

1. A New Interactive Interpreter (REPL)

The REPL (Read-Eval-Print Loop) is an interactive programming environment that reads user inputs, evaluates them, and prints the results. It’s particularly useful for testing snippets of code, debugging, and learning Python, as it provides instant feedback. The REPL is a key feature of Python, making it an ideal language for quick experimentation and iterative development.

Auto Indentation

In Python 3.12 REPL, the auto indentation was not available. To create block and indentation, we needed to press tab.

But in Python 3.13 REPL, when we will need to create block of code, after the first indented line, the next line will be auto-indented. Not only that, pressing tab will add 4 space at a time. So we would no longer need to press space 4 times (space space space space) to add indentation.

BLOCK-Level Code History

In Python 3.12 REPL, when we want to access the previous written codes, when we press the upper key and we get code line by line as it stores the code line by line and it is quite frustrating when editing a block level of code. We always need to press upper key many times, edit the code and again press the upper key many times.

But Python 3.13 REPL stores the code block wise, so pressing a single upper key would give us the whole block and we will be able to easily modify and make changes to a block of code.

exit Instead of exit()

In the Python 3.12 REPL version, typing exit, help, and quit throws an error. We always need to invoke exit, help or quit methods using the () operator. This is a silly approach.

But in Python 3.13 REPL, typing help will turn the REPL into help mode and typing exit will exit immediately from the REPL. That’s something really cool about the new REPL.

Easily Paste Code

In the Python 3.12 version of REPL, pasting code does not work as expected. We get errors like this. This is because after each line REPL thinks that we have pressed enter two times, so it executes the line and gives errors.

But the new REPL will have a great improvement that would allow us to simply paste copied code. Making it easier to work with copied code from some legit sources like GeeksForGeeks.

Other features of REPL:

  • Syntax Highlighting: The new REPL includes syntax highlighting, which enhances code readability by clearly differentiating keywords, variables, and other elements. This improvement aids developers in quickly understanding and debugging their code.
  • Colorized Prompts and Error Messages: With colorized prompts and error messages, the REPL offers better visibility and easier identification of code issues. This feature is particularly useful for improving error handling and debugging processes.
  • Multi-line Input Support: Developers can now enter multi-line code snippets directly within the REPL, facilitating more complex coding tasks without needing an external editor. This update streamlines the development workflow and enhances coding efficiency.
  • Improved Autocompletion and Help Modes: Enhanced autocompletion provides more accurate code suggestions, while new help and history modes allow users to access documentation and revisit previous commands easily.

That was all about the new REPL. Let’s us now see other released update on Python 3.13.

2. Just-In-Time (JIT) Compilation

Another major performance enhancement in Python 3.13 is the introduction of a Just-In-Time (JIT) compiler. JIT compilation is a technique that translates parts of the Python code into machine code at runtime, potentially speeding up the execution of certain programs.

This is particularly beneficial for performance-critical sections of code that are executed frequently. While Python has traditionally been known for its simplicity and ease of use rather than raw performance, the addition of a JIT compiler in Python 3.13 is a step towards making the language more competitive with other high-performance languages.

To use the JIT, CPython must be built with the --enable-experimental-jit option. This JIT compiler translates specialized Tier 1 bytecode into an intermediate representation (IR), known as Tier 2 IR, which can be further optimized and translated into machine code for execution.

The JIT can be configured with several options:

  • no: Disables the Tier 2 and JIT pipeline.
  • yes: Enables the JIT, with the option to disable it at runtime.
  • yes-off: Builds the JIT but disables it by default.
  • interpreter: Enables the Tier 2 interpreter while disabling the JIT.

The Tier 2 IR is optimized and then either interpreted or translated into machine code using a process called “copy-and-patch,” which requires LLVM at build time. This JIT feature is experimental and includes detailed optimizations to improve performance.

3. Python in a free-threaded mode or No GIL Mode

One of the most notable changes is the introduction of Free-Threaded CPython, which allows the Python interpreter to run without the Global Interpreter Lock (GIL). This has been a highly anticipated feature, as the GIL has long been a limiting factor in Python’s ability to fully utilize multi-core processors.

Python 3.13 introduces experimental support for a free-threaded mode where the GIL is disabled. This mode is not enabled by default due to its experimental nature, but it can be activated by using a different executable (python3.13t or python3.13t.exe), or by building Python from source with the --disable-gil option.

Key Points:

  • Experimental Feature: The free-threaded mode is still in the experimental stage, meaning it is not stable enough for production use, and users should expect some bugs and performance overheads in single-threaded contexts.
  • Parallel Execution: This mode enables true parallelism, allowing multiple threads to execute Python bytecode simultaneously, thereby potentially speeding up programs that are designed to take advantage of multi-threading.
  • Performance Trade-Offs: While free-threaded execution can enhance performance in multi-threaded applications, it may incur a performance hit in single-threaded programs. This is because the absence of the GIL introduces the need for more complex memory management mechanisms.

Developers interested in testing this feature can experiment with the free-threaded build of Python 3.13 and provide feedback to help improve its stability and performance in future releases.

Other Updates on Python 3.13

  1. Docstring Whitespace Stripping: The compiler now removes common leading whitespace from each line of a docstring, reducing the bytecode cache size by around 5% (e.g., in SQLAlchemy).
  2. Annotation Scopes: Annotations within class scopes can now include lambdas and comprehensions, which are no longer inlined into their parent scope.
  3. Future Statements: Relative imports from the __future__ module no longer trigger future statements.
  4. Global Declarations in except Blocks: global declarations are now allowed in except blocks when the global is used in the else block, fixing a previous SyntaxError.
  5. Frozen Modules Control: The new PYTHON_FROZEN_MODULES environment variable controls whether frozen modules are ignored, similar to the -X frozen_modules option.
  6. Performance Profiling: Support added for the perf profiler without frame pointers through PYTHON_PERF_JIT_SUPPORT and -X perf_jit.
  7. History File Location: The .python_history file’s location can be modified via the PYTHON_HISTORY environment variable.
  8. Static Attributes in Classes: Classes now have a __static_attributes__ attribute listing attribute names assigned via self.<name>.
  9. Class Line Number: Classes now include a __firstlineno__ attribute indicating the first line number of the class definition.
  10. exec() and eval() Enhancements: These builtins now accept globals and locals as keyword arguments.

Conclusion

Python 3.13 is shaping up to be a significant milestone in the evolution of the Python language, offering a variety of features that enhance both performance and usability. From the revamped REPL to the experimental JIT compiler and free-threaded mode, this release introduces powerful tools that cater to developers’ needs for speed, efficiency, and modern programming practices. While many of these features are still in their experimental stages, they provide a glimpse into the future direction of Python, making it a more versatile and competitive language.

For more information on Python 3.13 and to access the latest documentation, visit the official Python website.



Previous Article
Next Article

Similar Reads

Google Releases Studio Bot - Game-Changing AI Coding Bot for Android Developers
Google has unveiled its latest innovation in the field of artificial intelligence: Studio Bot, an advanced coding bot specifically designed to assist Android developers in creating remarkable applications. This cutting-edge AI-powered tool is poised to revolutionize the development process by generating code, rectifying bugs, and providing expert g
3 min read
AI startup Haiper raises $13.8M and releases video creation foundation model
Founded in late 2021 by Dr. Yishu Miao and Dr. Ziyu Wang, both Ph.D. graduates in machine learning from Oxford University and former DeepMind researchers, Haiper is poised to revolutionize video creation with its cutting-edge AI model. This latest funding round, led by Octopus Ventures, fuels the company's mission to democratize video production an
6 min read
Google Releases ‘Prompting Guide’ With Tips For Gemini In Workspace
The future of work is here, and Google is at the forefront of innovation with Gemini, its powerful large language model (LLM) assistant for Google Workspace. To help users use the full potential of Gemini, Google has released a detailed Gemini prompting guide. This article offers a roadmap for crafting effective prompts, enabling users to leverage
6 min read
UAE Releases New Falcon AI Model to Challenge Meta, OpenAI
The United Arab Emirates (UAE) has made a bold statement in the Artificial Intelligence (AI) race with the release of its latest Large Language Model (LLM), Falcon 2 developed by the Abu Dhabi Technology Innovation Institute (TII), Falcon 2 positions itself as a serious Meta AI and OpenAI competitors, boasting advanced capabilities and open-source
5 min read
Elon Musk's xAI releases Grok-2 AI assistant
Elon Musk's xAI has officially released Grok-2, the latest advancement in artificial intelligence (AI) from the innovative minds at xAI. Known for pushing the boundaries of technology, Elon Musk and his team at xAI have developed Grok-2 to offer exceptional abilities in machine learning, natural language processing (NLP), and autonomous decision-ma
8 min read
10 Best Roleplay AI Chatbots for Enhanced Creativity in 2024
Today, we use technology a lot in our everyday lives. It’s a big part of how we do things. One of the new things in technology is roleplaying AI chatbots. These are like digital friends who can tell stories and talk to us. They help us to be more creative and to think in new ways. They can tell detailed stories and have deep conversations with us.
9 min read
Microsoft Edge to Introduce a Secondary Search Bar: A Step Towards Enhanced Productivity
Microsoft Edge, the well-known web browser, is set to introduce a secondary search bar. This new feature aims to enhance productivity and provide instant access to relevant data. Microsoft Edge's New Feature Microsoft Edge is introducing a new feature - a secondary search bar. This isn't for typing web addresses, but for doing searches on search en
5 min read
7 Best ChatGPT Plugin for Enhanced Web Browsing Experience
If you are wondering what more you can do with ChatGPT, you can add many functionalities and features to ChatGPT through the best ChatGPT plugins. These best ChatGPT plugins for enhanced web browsing plugins will search different databases and fetch you relevant and accurate information. We will also guide you with installing these plugins seamless
9 min read
10 Useful Python One Liners That Developers Must Know
Python is known for its easy-to-code and intuitive syntax. And one-liners are like the cherry on the cake which makes Python a more beautiful and beloved programming language. There are numerous features in Python Language and one of its most loved features is its one-liners. Writing Code in Python is already easy compared to other programming lang
10 min read
7 Best Python IDE For Developers in 2021
Whether we talk about Data Science or Website Development or Artificial Intelligence &amp; Machine Learning or any other domain, there is one thing common in all these areas - Python! The language has experienced significant growth in its demand and popularity in the last few years and is currently ranking at the #1 position at various renowned ind
8 min read
11 pip Commands For Python Developers
Python has been preferred over all programming languages for technological advancement. It is one of the most lucrative programming languages that is used as the main programming language by more than 80%of developers. It is used for web development, mobile applications, hardware programming, and many more. Pip commands cannot be ignored when we ta
5 min read
Top 12 Python Scripts For Developers to Implement
Python is a widely used high-level, general-purpose programming language. This language can be used in web development, machine learning applications, and all cutting-edge software technology and is preferred for both beginners as well as experienced software developers. Developers spent most of their time developing or working with scripts. Python
11 min read
7 Cool Python Project Ideas for Intermediate Developers
Python in the world of programming everyone is familiar with the popularity of this language. Learning python and building the project is always an amazing experience for developers. This language really deserves hype in today's era and why not if it can solve a lot of real-world problems. Well, every programmer's journey starts with learning the b
12 min read
Level up your ChatGPT Game with OpenAI's Free Course on Prompt Engineering for Developers
Want to learn Prompt Engineering? OpenAI made it possible for you! The parent company of ChatGPT launched a free ChatGPT course on prompt engineering for developers. An interesting new course on prompt engineering called "ChatGPT Prompt Engineering for Developers" has been curated by renowned artificial intelligence (AI) experts Andrew Ng from Deep
3 min read
Apple Announces Worldwide Developers Conference Starting From 6th June
Synopsis: The Worldwide Developers Conference (WWDC) will showcase many events such as the latest innovations in various Apple products, including macOS, iOS, watchOS, iPadOS, and tvOS. Apart from this, the event will also provide a chance for the developers to access Apple engineers and technologies. On Tuesday Apple announced its Annual Worldwide
3 min read
Apple Will Soon Let Developers To Automatically Charge Users For Subscription
Synopsis: However in the new rule, Apple is taking away all the chance from the customers and is forcing them to use the application on the prices they provide, thus taking away all the choices of canceling the subscription. For a long time, Apple has become a subject of litigation and debate and now it is again on the verge of facing another issue
3 min read
10 Best ChatGPT Plugin for Developers in 2024
ChatGPT is a breakthrough in the technological world. This one tool enables developers, testers, project managers, designers, and people of other professions to provide the prompt and get answers. Most of the benefits are reaped by developers using the best ChatGPT Plugin for Developers. You can use and generate the code for the given requirement w
10 min read
10 Best ChatGPT Prompts for Coders/Developers in 2024
Whether you’re a beginner embarking on your coding journey or an experienced programmer looking to fine-tune your algorithms, the practical assistance offered by these prompts is invaluable. Discover the importance of incorporating ChatGPT into your coding arsenal, a tool that facilitates efficient problem-solving, debugging, and seamless API integ
9 min read
7 Best Generative AI Tools for Developers [2024]
In the rapidly evolving world of technology, generative Artificial intelligence (AI) tools for developers have become indispensable assets for innovation and efficiency. These cutting-edge tools harness the power of advanced algorithms and machine learning techniques to autonomously generate content, designs, and code, transforming the development
9 min read
Top 10 Free and Paid Claude AI Alternatives for Writers and Developers in 2024
AI has started influencing content creation at scale. The whole momentum picked up pace as Open AI launched ChatGPT in November 2022. Content marketing revenue in 2023 was roughly $72 billion but it is growing massively. As per Statista, Content marketing revenue will cross over $107 billion in 2026. We are still in the early days of smarter AI and
10 min read
Django Interview Questions & Answers With Practical Tips For Junior Developers
Django... Isn't it your favorite framework? (especially if you are new to the programming world) Yes! It is... Did you try to learn this framework and build some projects? If the answer is Yes then here is the next question... Did you understand the complete flow of the project? Again if the answer is Yes then here is another question (don't get an
15+ min read
Top 10 Discord Servers for Developers
In the dynamic field of software development, it's important to stay updated and keep up relationships with like-minded individuals. Discord was originally a platform for gamers. Discord has grown into a dynamic community where developers can share information, collaborate on projects, and seek guidance. With so many servers dedicated to different
10 min read
Best App Developers in USA
Mobile app development has become crucial for businesses aiming to enhance customer engagement and streamline operations. As a critical component of modern technology, mobile apps offer personalized experiences, convenience, and accessibility to users. If you're continuously searching for app developers near me then this article explores the top mo
8 min read
Top 20 Programming Languages to Learn in 2024: A Complete List for Developers
Are you wondering which programming languages will dominate the tech world in 2024? Curious about which skills will be most in demand by employers? Or perhaps you're trying to figure out which programming language is the best fit for your career growth? The answers to these questions are more critical now than ever, as the right choice can shape th
15+ min read
Important differences between Python 2.x and Python 3.x with examples
In this article, we will see some important differences between Python 2.x and Python 3.x with the help of some examples. Differences between Python 2.x and Python 3.x Here, we will see the differences in the following libraries and modules: Division operatorprint functionUnicodexrangeError Handling_future_ modulePython Division operatorIf we are p
5 min read
Python program to build flashcard using class in Python
In this article, we will see how to build a flashcard using class in python. A flashcard is a card having information on both sides, which can be used as an aid in memoization. Flashcards usually have a question on one side and an answer on the other. Particularly in this article, we are going to create flashcards that will be having a word and its
2 min read
Reading Python File-Like Objects from C | Python
Writing C extension code that consumes data from any Python file-like object (e.g., normal files, StringIO objects, etc.). read() method has to be repeatedly invoke to consume data on a file-like object and take steps to properly decode the resulting data. Given below is a C extension function that merely consumes all of the data on a file-like obj
3 min read
Python | Add Logging to a Python Script
In this article, we will learn how to have scripts and simple programs to write diagnostic information to log files. Code #1 : Using the logging module to add logging to a simple program import logging def main(): # Configure the logging system logging.basicConfig(filename ='app.log', level = logging.ERROR) # Variables (to make the calls that follo
2 min read
Python | Add Logging to Python Libraries
In this article, we will learn how to add a logging capability to a library, but don’t want it to interfere with programs that don’t use logging. For libraries that want to perform logging, create a dedicated logger object, and initially configure it as shown in the code below - Code #1 : C/C++ Code # abc.py import logging log = logging.getLogger(_
2 min read
JavaScript vs Python : Can Python Overtop JavaScript by 2020?
This is the Clash of the Titans!! And no...I am not talking about the Hollywood movie (don’t bother watching it...it's horrible!). I am talking about JavaScript and Python, two of the most popular programming languages in existence today. JavaScript is currently the most commonly used programming language (and has been for quite some time!) but now
5 min read
Practice Tags :