bpo-33872: Add list elements access complexity by andresdelfino · Pull Request #7728 · python/cpython

@andresdelfino

@andresdelfino

pablogsal

Lists are mutable sequences, typically used to store collections of
homogeneous items (where the precise degree of similarity will vary by
application).
application). List elements are accessed with a O(1).

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggestion: "List elements are accessed with O(1) time complexity" or "Accessing list elements has O(1) time complexity".

"List elements are accessed with a O(1)" sounds a bit off to me.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IMHO, mentioning "time complexity" is definitely an improvement, I'll rephrase, thanks :)

@andresdelfino

We are not talking much about time complexity in other parts of the documentation. Change it to mimic the intention in the Glossary: avoid the confusion with linked lists.

vadmium

application).

Despite its name, lists are more akin to arrays in other languages than to
linked lists, since its elements are accessed with time complexity O(1).

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use plural: “their name”, “their elements”, to agree with “lists are”

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

😅 thanks!

@andresdelfino

@andresdelfino

methane

homogeneous items (where the precise degree of similarity will vary by
application).

Despite their name, lists are more akin to arrays in other languages than to

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

“despite their name” seems redundant.
“List” is datastructure independent, abstract word.
For example, C# uses IList and ArrayList for sequence (indexable). And LinkedList for linked list.