Python 3 Compatibility: What To Know
Compatibility is a moving target. This is particularly true for backwards-incompatible languages such as Python 3, as it forces developers to shoehorn Python 3 features into Python 2 via backporting. We’ve recently updated our platform to be compatible with Python 3.6. Here’s what that means:
Running a supported version of Python is important, since unsupported versions are not only more likely to have vulnerabilities, but won’t receive patches on detected vulnerabilities. With 3.6, you’re able to integrate third-party dependencies that rely on Python 3, including running the latest Celery and Django dependencies.
Introduced at Python 3.5, type hinting is a formal solution that indicates different values within your Python code. The labels produced by type hinting help the interpreter better understand your code’s behavior. With it, you can uniformly annotate the types of Python functions, arguments, and variables across various tools.
Sentry ingests an astronomical number of events per second. Due to our large volume of event ingestion, our Kafka consumers are getting close to the maximum number of events they can process. A typical way to continue to scale here is to use multithreading to allow each consumer to make use of multiple cores on their machine. Unfortunately, due to Python’s Global Interpreter Lock, we are unable to do this in Python as we’re primarily CPU constrained.
Another option is to use multiprocessing. This can work, but comes with higher overheads for sharing data between processes. In previous versions of Python these costs would likely have been prohibitive, but thankfully, there’s a solution on the horizon, as Python’s multiprocessing.shared_memory module provides a mechanism for efficiently sharing binary data between processes with minimal overhead. While this solution is in 3.8, supporting Python 3.6 gets us one step closer to our goal here.
It’s undeniable that Python 3.6 will make Sentry more efficient. After Instagram implemented their 3.6 patch, they noticed a 12 percent CPU savings on Django, and 30 percent memory savings on Celery. But more than any memory savings or new integration, this update represents another step in making Sentry that much more compatible for your needs.
If you’re a person who finds Python compatibility interesting, we’re a company that will find you interesting. Check out our open roles here.