I’m starting to see more and more useful features in Python versions > 3.7, and I’d like to plant a seed to upgrade TD’s Python to a new version.
Here are some of the new features in Python > 3.7 I’d like to use:
-
multiprocessing.shared_memory
(python 3.8)
This is my number one, it seems super useful to communicate large amounts of data (like numpy arrays) between TD and any external Python process I have started. I can already hack something like this using mmap, but this is so much more streamlined. -
Simpler updating of dictionaries with union (
|
) and in-place union (|=
). You can use|
to merge two dictionaries, while|=
will update a dictionary in place (python 3.9)
z = x | y
- Debugging using f-strings. I use f-strings all the time, and this new debug feature is simple & sweet. Just add =. (python 3.8)
>>> python = 3.8
>>> f"{python=}"
'python=3.8'
- the walrus operator, which was quite a discussion, but it has landed now, see:
Assignment Expressions: The Walrus Operator – Real Python (since python 3.8)
what are your favorites?