Close

2023-10-11

Meta’s Contribution to Python 3.12: A Dive into New Features and Improvements

Meta's Contribution to Python 3.12: A Dive into New Features and Improvements

Python 3.12 has been released, and it brings a plethora of new features and performance enhancements. Some of these improvements have been contributed by Meta, showcasing their commitment to the Python community. Here are the key highlights from the article:

  • Immortal Objects: Introduced through PEP 683, Immortal Objects are Python objects that don’t participate in reference counting and live until the Python interpreter shuts down. This feature aims to reduce memory usage and pave the way for truly immutable Python objects that can be shared between interpreters without locking.
  • Type System Improvements: The engineering team behind Pyre, an open-source Python type-checker, introduced PEP 698, which adds a @typing.override decorator. This helps developers avoid bugs when refactoring class inheritance hierarchies that use method overriding.
  • Performance Optimizations: Python 3.12 introduces several performance enhancements, including faster comprehensions, eager asyncio tasks, faster super() calls, and more.
  • New Benchmarks: To better represent workload characteristics seen at Meta, new benchmarks have been added to the Python Performance Benchmark suite.
  • Cinder Hooks: Meta has been sharing its work on Python and CPython through its open-source Python runtime, Cinder. For Python 3.12, several new hooks have been introduced in the core runtime to support third-party JIT compilers or runtime optimizers for CPython.
  • Beyond Python 3.12: Meta’s involvement with Python doesn’t end with this release. They are actively discussing proposals like PEP 703 to remove the Global Interpreter Lock (GIL) and allow Python to run in multiple threads in parallel. Additionally, Meta continues to support the Python community through sponsorships, talks, and contributions.

Reference: Engineering at Meta.