Five days ago, a new release of version 3.9 appeared with a series of improvements and new python packages, see the official website.
You can install easily on Fedora 32 with dnf tool.
[root@desk mythcat]# dnf install python39.x86_64
...
Installing:
python39 x86_64 3.9.0-1.fc32
...
Installed:
python39-3.9.0-1.fc32.x86_64
Complete!
A new article written about this release shows some of the advantages of this programming language, you can read it here. You can run easily with this command;
[root@desk mythcat]# python3.9
Python 3.9.0 (default, Oct 6 2020, 00:00:00)
[GCC 10.2.1 20200723 (Red Hat 10.2.1-1)] on linux
Type "help", "copyright", "credits" or "license" for more information.
You can configure python with this command, see an example:
[root@desk mythcat]# python3.9-x86_64-config --libs
-lcrypt -lpthread -ldl -lutil -lm -lm
This release of Python 3.9 uses a new parser, based on parsing expression grammar (PEG) instead of LL(1) know as LL parser (Left-to-right, Leftmost derivation).
PEG parsers are more powerful than LL(1) parsers and avoid the need for special hacks.
This the same abstract syntax tree (AST) as the old LL(1) parser.
The PEG parser is the default, but you can run your program using the old parser, see the next example:
[mythcat@desk ~]$ python3.9 -X oldparser my_script_name.py
...
One of the most important improvements for me is PEP 614 -- Relaxing Grammar Restrictions On Decorators.
In Python 3.9, these restrictions are lifted and you can now use any expression. For example including one accessing items in a dictionary, like this simple example:
buttons = {
"hello": QPushButton("hello word!"),
"bye": QPushButton("bye word!"),
"buy": QPushButton("buy!!"),
}
...
@buttons["hello"].clicked.connect
def speak_hello():
...
Yes, comes with another Python Enhancement Proposals - PEP 615 with support for the IANA Time Zone Database in the Standard Library.
This acronym is similar to I.A.N.A known as the Internet Assigned Numbers Authority, but it is not the same. In this case, the zoneinfo module provides a concrete time zone implementation to support the IANA time zone database.
This support contains code and data that represent the history of local time for many representative locations around the globe.
Many features for math, strings, union operator for the dictionary, HTTP codes, and more.
Completion of variable and module names is automatically enabled at interpreter startup so that the Tab key invokes the completion function.
You can see a simple example with zoneinfo python module and completion feature.
[mythcat@desk ~]$ python3.9
Python 3.9.0 (default, Oct 6 2020, 00:00:00)
[GCC 10.2.1 20200723 (Red Hat 10.2.1-1)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from zoneinfo import ZoneInfo
>>> import zoneinfo
>>> zoneinfo.available_timezones()
{'Hongkong', 'America/Iqaluit', 'America/Indianapolis', 'America/Louisville', 'America/New_York',
'America/Mazatlan', 'Australia/Yancowinna', 'Africa/Ndjamena', 'Portugal', 'Africa/Bujumbura',
'America/Rosario', 'America/Antigua','America/Indiana/Tell_City', 'America/Managua',
'Europe/Paris', 'Europe/Oslo',
...
>>> tz = ZoneInfo("Europe/Bucharest")
>>> tz.
tz.clear_cache( tz.from_file( tz.key tz.tzname(
tz.dst( tz.fromutc( tz.no_cache( tz.utcoffset(
>>> tz.
On my desktop I got this result:
[mythcat@desk ~]$ python var_access_benchmark.py
Variable and attribute read access:
6.0 ns read_local
6.5 ns read_nonlocal
10.7 ns read_global
10.7 ns read_builtin
25.2 ns read_classvar_from_class
23.4 ns read_classvar_from_instance
34.3 ns read_instancevar
29.4 ns read_instancevar_slots
26.8 ns read_namedtuple
42.4 ns read_boundmethod
Variable and attribute write access:
6.6 ns write_local
7.0 ns write_nonlocal
23.3 ns write_global
54.1 ns write_classvar
46.4 ns write_instancevar
39.4 ns write_instancevar_slots
Data structure read access:
26.1 ns read_list
28.1 ns read_deque
27.5 ns read_dict
25.8 ns read_strdict
Data structure write access:
29.6 ns write_list
31.7 ns write_deque
34.4 ns write_dict
31.7 ns write_strdict
Stack (or queue) operations:
55.5 ns list_append_pop
49.7 ns deque_append_pop
51.0 ns deque_append_popleft
Timing loop overhead:
0.4 ns loop_overhead