[ase-users] [EXTERNAL] Python3.5 vs 3.6 support
Hermes, Eric
ehermes at sandia.gov
Wed Feb 26 17:27:39 CET 2020
On Wednesday, February 26, 2020 4:00:03 AM PST Adam Jackson via ase-users
wrote:
> +1 for Python 3.6 here. It has now been available for nearly 5 years and is
> installed on all the cluster facilities I have recently used.
> > > So, insertion-order dicts are considered an "implementation detail" in
> > > Python 3.6. It's only an official language feature in Python 3.7+.
> > > Practically speaking, this may be a distinction without a difference,
> > > but generally I think we ought not to rely on "unofficial" behavior
> > > like this.
> >
> > In our case we are in the clear: We only support CPython, and the
> > insertion ordering is now a historical fact of CPython 3.6.
> >
> > If we supported other Python implementations such as Jython,
> > IronPython, or PyPy, it would not have been okay until 3.7.
>
> On the matter of ordered dictionaries, I would suggest using
> collections.OrderedDict if the ordered behaviour is important. As well as
> providing compatibility *today* it will make the code easier to understand,
> especially for any contributors unfamiliar with the new behaviour. Do be
> aware however that equality comparison between OrderedDicts is sensitive to
> order, while comparison between 3.6+ dicts is not.
> From the Zen of Python:
> > Explicit is better than implicit
The problem is that it isn't possible to use OrderedDicts where it really
matters, i.e. in the **kwargs arguments to Calculators and input file writers.
OrderedDicts are also sufficiently different from regular dictionaries in other
ways (e.g. comparison with == considers both order and content) that switching
to OrderedDicts everywhere would possibly be a breaking change. "Insertion-
order" dicts, on the other hand, are just regular Python dicts with the
incidental behavior that iterating over them is deterministic.
>
> -Adam
>
> _______________________________________________
> ase-users mailing list
> ase-users at listserv.fysik.dtu.dk
> https://listserv.fysik.dtu.dk/mailman/listinfo/ase-users
--
Eric Hermes
Postdoctoral Researcher
Sandia National Laboratories
More information about the ase-users
mailing list