New releases from Python and Jython on their way

The Python 3.5 proposal supports async and await syntax, while Jython 2.7 gets faster in its latest instalment. We check out what’s new with the object-oriented programming language and the successor to JPython.
In Python Enhancement Proposal (PEP) #0492, Python 3.5 will support asynchronous programming with the inclusion of async and await syntax, making coroutines a native Python language feature. With this proposal, Yury Selivanov hopes to “keep Python relevant and competitive in a quickly growing area of asynchronous programming”.
The PEP shows how the new syntax is used to declare a native coroutine:
async def read_data(db): pass
Key properties of the new feature mean that async def
functions are always coroutines, even if they do not contain await
expressions. The PEP states that it’s a SyntaxError
to have yield
or yield from
expressions in an async
function. The new coroutine declaration syntax also internally introduces two new code object flags:
CO_COROUTINE
is used to enable runtime detection of coroutines (and migrating existing code)CO_NATIVE_COROUTINE
is used to mark native coroutines (defined with new syntax)
All coroutines have CO_COROUTINE
, CO_NATIVE_COROUTINE
, and CO_GENERATOR
flags set.
As for await
expressions, these are used to obtain a result of coroutine execution:
async def read_data(db): data = await db.fetch('SELECT ...') ...
Some examples of await
expressions have been published in the PEP as the following:
Expression | Will be parsed as |
---|---|
if await fut: pass |
if (await fut): pass |
if await fut + 1: pass |
if (await fut) + 1: pass |
pair = await fut, 'spam' |
pair = (await fut), 'spam' |
A full list of expressions, complete with invalid syntax examples and further information, can be found in the above mentioned PEP #0492.
Jython 2.7.0 final released
Jython developer Frank Wierzbicki has announced the release of Jython 2.7 after several betas and three release candidates. Described as complementary to Java, the Python-implementation language boasts language and runtime compatibility with CPython 2.7 and substantial support of the Python ecosystem.
SEE ALSO: Java + Python: Jython 2.7 beta 3 has arrived
New features include built-in support of pip/setuptools and a native launcher for Windows (bin/jython.exe), with the implication that you can now install Jython scripts on Windows.
Jim Baker appeared at PyCon 2015 and presented demos and new features of Jython’s latest shipment, which can be see here.