Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

What Java, JavaScript and C# call "arrays" are each very much like what Python calls "lists'. In particular the indexing after push() and pop() type operations and the bigO of indexing.

More abstractly, Historically, in computing "list" connotes pointers and "array" connotes sequential memory. The connotations imply engineering tradeoffs. [1] "List" may make more sense for a beginning programmer. It is an arbitrary context switch for programmers writing in multiple languages. Considering that one of the driving use cases of Python has been systems programming, "list" is misleading regarding performance characteristics. [2]

[1]: For example as in Scala https://docs.scala-lang.org/overviews/collections/performanc...

[2]: googling "python arrays" returns a lot of results explaining the difference between Python's Arrays and Python's Lists. "List" is "foo => spam" and "bar => eggs" Pythonism gone too far.



Not true for Java or C#. In both of those languages, arrays are fixed-size and don't have anything like a push or pop operation. Both have an automatically resizing container backed by an array that is referred to as a list. Python's use of "list" matches the use in Java and C# perfectly.


Requiring a type definition, Python's Array type more closely matches Java and C# Lists than Python's List type.

In Python, Arrays are sequence types and behave very much like lists[1] In other words, even in Python, arrays have similar semantics to Javascript Arrays not Java Arrays.

[1] https://docs.python.org/3.4/library/array.html


  What Java, JavaScript and C# call "arrays"
  are each very much like what Python calls
  "lists'.
In Java and C#, 'arrays' are fixed size at creation time.

Both Java and C# provide 'lists' which are variable sized*

Python 'lists' are variable-sized.

Seems like a consistent naming scheme to me?

*there might be an underlying array that gets reallocated - but it's encapsulated within the list object; the reference to the list object is unchanged when this happens.


Fair point, technically.

But Python predates C# and Java.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: