What is the `===` specifier?

Today I was reading the pip source code and found this interesting bit:

And wondered what this === operator was. It turns out it’s briefly mentioned in PEP 508:

But it’s not really explained. Search engines are not very good at symbols so I’m left wondering what this is and how can it be used?

Arbitrary equality comparisons are simple string equality operations which do not take into account any of the semantic information such as zero padding or local versions. This operator also does not support prefix matching as the == operator does.

The primary use case for arbitrary equality is to allow for specifying a version which cannot otherwise be represented by this PEP. This operator is special and acts as an escape hatch to allow someone using a tool which implements this PEP to still install a legacy version which is otherwise incompatible with this PEP.

An example would be ===foobar which would match a version of foobar.

This operator may also be used to explicitly require an unpatched version of a project such as ===1.0 which would not match for a version 1.0+downstream1.

Use of this operator is heavily discouraged and tooling MAY display a warning when it is used.

Arbitrary equality” chapter of PEP 440

3 Likes

Use of this operator is heavily discouraged and tooling MAY display a warning when it is used.

Thanks!