6 ESSENTIAL LIBRARIES FOR EVERY PYTHON DEVELOPER
Python has seen wide adoption across industries and disciplines by dint of being easy to work with. But it has also been aided by a wealth of third-party projects—libraries, add-ons, and complementary development efforts—that extend the language to an ever widening range of use cases.
Some of these projects, like PyInstaller and WxPython, shine for Python developers who are building desktop and end-user apps. Others, like PyPy, are used to give server-side Python apps extra oomph. And others, like PBR, CFFI, and MyPy, are useful for developing all kinds of Python apps, no matter where they might run.
If you’re a Python developer, all six of these projects are worth getting familiar with. And all six have rolled out major new versions in recent weeks.
Essential Python: PyPy
What is PyPy used for?
If you want faster Python apps, the easiest way to get them is by way of PyPy, the Python runtime with a just-in-time (JIT) compiler. Python apps JITted with PyPy run on the average 7.5 times faster than their regular Python counterparts. Unfortunately, PyPy hasn’t always played well with many of Python’s star frameworks. PyPy 5.9 makes major strides towards fixing that problem.
PyPy 5.9 features
Data science frameworks NumPy and Pandas now run on PyPy’s Python 2.7-compatible version. Most of the problems around those frameworks stemmed from how PyPy interfaced with existing C code. To address that, PyPy 5.9 rolled in improvements to the CFFI library (see below) and PyPy’s Python C API compatibility layer.
Also with the version 5.9 release, PyPy’s JSON parser is now significantly faster when processing many kinds of JSON objects, especially those with repeated uses of the same dictionary keys.
Where to download PyPy 5.9
You can download binaries for PyPy directly from its site. Official binaries are available for Windows, Mac OS, and Linux on different CPU architectures. Note that different binaries exist for Python 2.7 and Python 3.5 compatibility, so be sure you’re fetching the version that matches the scripts you’ll be running.
Essential Python: CFFI
What is CFFI used for?
The C Foreign Function Interface library, or CFFI, provides a way for Python applications to interoperate with standalone C libraries. Although the stock version of Python, CPython, has its own library for this kind of work, called Ctypes, CFFI makes interacting with C libraries easier and more idiomatic for Python users than Ctypes does.
CFFI 1.11 features
CFFI v1.11, updated in conjunction with PyPy, adds minor but useful changes. It now works with betas for the forthcoming Python 3.7, has better support for external error handling on Windows, and supports more modern standard types in C, such as
float/double _Complex and the
char_32t types. Those last two are most crucial for C libraries that use Unicode internally.
Where to download CFFI 1.11
CFFI is available as a standalone download from the Python Package Index, or can be installed with Python’s
pip install cffi. Source code and bug tracking is available on BitBucket.
Essential Python: PyInstaller
What is PyInstaller used for?
One of the most commonly asked questions about Python is, “How can I generate a standalone executable from a Python script?” PyInstaller has long been one of the best answers.
PyInstaller 3.3 features
PyInstaller packages a Python app into a single directory or single-file executable, bundles any needed third-party libraries along with it, and works with the vast majority of common libraries and frameworks.
The biggest improvement in PyInstaller 3.3 is support for Python 3.6, something sorely lacking since Python 3.6 arrived. PyInstaller 3.3 also includes a more broadly compatible bootloader for Windows executables, and expanded support for bundling common libraries like QT, GTK+, NumPy, and Django.
One feature that PyInstaller isn’t likely to add anytime soon is cross-packaging—e.g., creating a Mac-compatible app on Windows. You’ll need to run PyInstaller on the same platform you want to deploy to, whether Windows, Mac, or Linux.
Where to download PyInstaller 3.3
PyInstaller can be installed from the Python Package Index, or installed with Python’s
pip install pyinstaller. Source code is available on GitHub for those who want to compile the bootloaders themselves, but most people will not need to do this.
Essential Python: Python Build Reasonableness (PBR)
What is Python PBR used for?
Setuptools is the standard-issue Python subsystem for packaging Python projects. Managing Setuptools for a given project can become fiddly and tedious, especially when auto-generating requirements, managing documentation files, or editing data on project contributors.
Python PBR features
PBR, short for Python Build Reasonableness, is a library for managing Setuptools packaging in a consistent manner. It automates many aspects of Setuptools packaging, such as version numbering, generating Authors and ChangeLog files, and producing Sphinx-style documentation. PBR was originally developed as part of the OpenStack project, but nothing you maintain with PBR has to be connected to OpenStack in any way.
Where to download Python PBR
Essential Python: WxPython
What is WxPython used for?
Python developers who want to make cross-platform desktop applications can choose from a number of toolkits. WxPython, a wrapper for the WxWidgets library, uses native UI elements for its supported host platforms, which include Windows, Mac, Linux, and other Unix-like operating systems.
WxPython 4.0 features
Earlier versions of WxPython were weighted down with legacy design decisions, making it slower and less appealing to work with. To fix this, the developers of WxPython have made major changes to WxPython’s 4.0 branch.
The goal is to allow developers to get started more quickly with WxPython, and to make both the framework and the applications created with it more performant and easier to maintain. Any existing WxPython projects will need to be modified to use WxPython 4.0, however.
Where to download WxPython 4.0
WxPython 4.0 is still officially in beta. It’s available on the Python Package Index by way of
pip install wxpython, but it may be updated several more times before being formally released. Check back often for updates.
Those who want to hack on it directly can check out the GitHub repository. Note that the 4.0 branch of WxPython is branded with the codename “Phoenix” to keep it distinct from earlier versions.
Essential Python: Mypy
What is Mypy used for?
Python’s dynamism is both a boon and a bother—great for building software fast, but not so great when it makes code difficult to reason about, test, and debug. Mypy adds static type checking to Python at compile time, making Python programs more consistent and maintainable but without adding runtime overhead.
Mypy 0.530 features
Mypy 0.530 adds support for protocols, a currently experimental type feature for use in Python subclasses. It also adds the “TypedDict” type for dictionaries that are meant to contain only a specific kind of object, and options to enable stricter checking of types on a file-by-file basis.