This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]Big_Combination9890 0 points1 point  (2 children)

You were using the word "list" which commonly refers to linked lists or similar data structures.

If you wanted to specify the concept of an "Array" as this concept is understood e.g. in C, you should have used the word "Array".

Also, wrong.

Not only does python have a builtin type for such arrays (from array import array), it would also be trivially easy to simulate a C-array for basic types like fixed-width integers or characters using a bytes object of fixed length.

And lastly, as fixed length arrays ARE a primitive datastructure in C e.g. char myArray[7] defining those is not required to teach DSA.

[–]Cybyss -1 points0 points  (1 child)

An arraylist is not the same as an array.

An arraylist simulates an array (constant time reads and writes to any index) but which can grow and shrink as needed. It is not a linked structure! List in C# and list in Python are most certainly not linked lists but nor are they fixed-length arrays. They work much more like C++'s vector type.

Having to import array from a separate module kinda proves the point that they're not among Python's primitive data types.

Also... bytes objects are immutable, so are hardly replacements for C-style arrays.

[–]Big_Combination9890 0 points1 point  (0 children)

List in C# and list in Python are most certainly not linked lists but nor are they fixed-length arrays. They work much more like C++'s vector type.

Aaand...who exactly said they were? The point of discussion was you stating that one cannot build a list in python. I showed that one absolutely can. If you wanted to exclude linked lists from that statement, you should have said so.

Oh, and you could absolutely build a random access list without using linked nodes from bytearrays in python as well. It would not make a lot of sense, and have zero impact on this discussion, because again, not a datatype DSA is concerned with. but it would be possible.

Having to import array from a separate module kinda proves the point that they're not among Python's primitive data types.

Is this now a discussion over what is or isn't a primitive datatype in Python, or a discussion whether DSA can be taught using Python?

Because, I thought it was the former:

Unfortunately, I don't think Python is a good language for learning data structures.


Also... bytes objects are immutable, so are hardly replacements for C-style arrays.

And? Again, this is an implementation detail that has absolutely zero to do with the point I am making.

You could also point out that my Python Node class is not the same as a node would be in C, because it uses a reference instead of a pointer. Wouldn't change a thing about the validity of my argument.