On 3/27/24 9:52 AM, Bruno Haible wrote:
> I agree. My main considerations are:
> 
>   - Can someone with little exposure to Python understand and modify the
>     code? When you write 'list' and the developer knows that 'list' means
>     what is known as "array" in other programming languages, they can work
>     with the code. Using the abstract interfaces that Python has does not
>     help in this aspect.

That sounds like a pretty reasonable goal to prioritize when we make
changes. Sadly, the Python typing stuff is spread across many PEP's
and documentation pages which is annoying. It seems that they are
working on this, so hopefully things will be different in a year or
two.

>   - In some cases, it is useful to access the data structure with indices.
>     Then an 'Iterable' will not suffice, a 'list' or 'tuple' is needed.
>     What would be the point of declaring "this function needs to traverse
>     the given data only from the beginning to the end, never in the opposite
>     direction, never with random indices"? There is no advantage. It is
>     useless information. So, why bother?

If you need to describe a data structure with indices it seems you
would use 'Sequence' [1]. This table that I linked is a good reference
if we ever want to use more generic type hints. It seems the same PEP
that made 'list' preferred over 'List' for type hints made the
'collections.abc' module types preferred over their 'typing' module
variants.

[1] 
https://docs.python.org/3/library/collections.abc.html#collections-abstract-base-classes

Collin

Reply via email to