Now that our recent work on stacks has been completed we have some great news for the Python developers out there: Python 3.7 support is now publicly available on Scalingo! From now on, you can execute a Python 3.7 application in an instant.
Enabling Python 3.7 for Your App
Getting your application executed by the powerful Python 3.7 is as simple as specifying it in your Pipfile file:
[requires] python_version = "3.7"
If you already have an application running, just update your existing
file with a newer version. Then,
git commit and
git push this change.
What’s New in Python 3.7
This new release of Python features some significant updates to the language. Here are some of the most important ones.
await: Concurrency on Steroids
Python received some great new features in
asyncio, its concurrency library.
It also introduced two new keywords
await which makes it easier to
run functions asynchronously.
You first need to declare a coroutine using
async keyword. Then, calling such
coroutine is done by prefixing the call with
Here is an example of how to run concurrently two tasks:
import asyncio async def my_coroutine: asyncio.sleep(2) async def main: task1 = asyncio.create_task(my_coroutine()) task2 = asyncio.create_task(my_coroutine()) await task1 await task2 asyncio.run(main())
The new context variables feature is also here to improve concurrency in Python. This concept is similar to thread-local storage, but it also allows to correctly keep track of values per asynchronous task.
import contextvars import asyncio counter = contextvars.ContextVar("counter", default="0") async def set_one() counter.set("1") async def print_counter() print(count.get()) asyncio.run(set_one()) # Set the value of counter to 1 in a given context asyncio.run(print_counter()) # Prints "0" as it is executed in a different context
breakpoint: Ease the Developer’s Life
Python 3.7 introduces the new
breakpoint which only aims to simplify the
developer’s life. Simply calling
breakpoint() opens the debugger at the call
It may look like a small changes, but after a few days of using it, you will be convinced of the usefulness of this update!
Python 3.7 introduces a new
dataclass decorator which aims at simplifying the
writing of data class. A data class describes its attributes using class
variable annotations. All the magic methods are then automatically generated:
@dataclass class Point: x: float y: float z: float = 0.0 p = Point(1.5, 2.5) print(p) # produces "Point(x=1.5, y=2.5, z=0.0)"
Another great improvement of this release is about performance. The Python team worked hard to improve overall performances of Python program in various area. These improvements range from reducing the startup time of Python (10% reduction on Linux!) to rewriting many methods with performance in mind. The overhead of calling a single method has been reduced by up to 20% thanks to some byte code changes, and calling a method is probably something you do in your Python program!
Much More Things
Much more new wonderful things were released in this version such as the order
of dictionaries which is now preserved, better handling of the
DeprecationWarning, and a new development runtime mode… Read the full blog
for a comprehensive list of novelties.