[QGIS-Developer] [Qgis-user] Changes in Python versions on QGIS 3.18

Sebastian M. Ernst ernst at pleiszenburg.de
Thu Mar 25 04:59:28 PDT 2021


Hi Nyall,

> I'm curious -- what's the pain in a Python update? They usually have
> very little harmful impact on python code.

from a syntactical point of view, the language is usually only extended
- here, you are right for the most part (except for younger features
like the async stuff for instance). However, there are always edge-cases
in terms of behavior-changes in the interpreter, unfortunately.

>From a standard-library point of view, more and more depredations from
the earlier 3.x-days are now gradually being removed while many more
features have recently been added to the list of deprecations. Just for
example, 3.8 and 3.9:

https://docs.python.org/3.9/whatsnew/3.8.html#api-and-feature-removals
https://docs.python.org/3.9/whatsnew/3.9.html#removed

It's not a lot of stuff, but, from experience, it always requires proper
testing and minor fixes. Besides, there is always "this one dependency"
which has issues and is not fixed in time.

Things become a little more problematic when you are relying on the
interpreter's internals in one way of another. Every version sees
significant changes in its C API. If QGIS did not have any issues with
that recently, then you are lucky. Beyond that, every version -
especially recent ones - introduce a lot of changes at the byte-code
level. If you are, just as an example, relying on packages like `numba`,
which is becoming more and more common, then those byte-code-level
changes simply mean that you are unable to move to a younger version of
Python for quite a bit of time. As of today, strictly speaking, Python
3.9 has only been a "stable" option for many users for the past 9 days:

https://github.com/numba/numba/issues/6345
https://github.com/numba/numba/releases/tag/0.53.0

A clear Python upgrade policy for QGIS would be really helpful, allowing
developers to adjust their workflow accordingly. PEP 602 has recently
introduced clear rules for Python itself, i.e. an annual schedule. It
should be feasible to come up with a simple set of rules when QGIS
(and/or OSGeo4W for that matter) switches to a new version of Python.

https://www.python.org/dev/peps/pep-0602/

Best regards,
Sebastian


More information about the QGIS-Developer mailing list