It's all thanks to my parents forcing me when I was in high school. I promise you, everyone can learn to touch type, and you can/should learn as soon as you can!
@@symfoniatragic Thanks; I learned when I was in high school, and it was one of the best things I ever learned. I *hated* it when I had to learn, but I super appreciate it now. I'll try to do a video about tyouch typingn in the future!
that i mean arrays in Java or C are faster to iterate over when using primitive data types that is why Java has Int and Integer Object when building an Integer Object array its almost the same as python lists with set length. But when just using a primitive type Array the data will be stored in memory directly following each other and adding the size of your datatype to the array pointer will return the next data point for example Int64 add 64 to your pointer and there you have the pointer to the next element but with python you would have to dereference twice you increment the array pointer to get the pointer to your data. The way C implements this makes branch prediction really good because if you access one element of an Array you are likely to want to access all of them. So the CPU can just load all of them into Cache and provide access without having cache misses. Now python might do some stuff to mittigate this but over all its gonna be a little slower. That should also be the reason why Arrays in python are only implemented for primitive data types since otherwise lists and arrays seem to be the same.
I'd say the use case for python arrays is communicating with extension modules. If you want to pass a collection of say ints between the python code and the C code in an extension module the array.array structures allow this quite easily, because the data is already stored as a C array and can be used without complicated copying in the glue code.
That's a very good point! I haven't written extension modules in C or any other language, but I do remember reading/seeing that arrays make it easier to do that. Thanks for the comment!
The array does not allow adding elements. If elements can be added, then it is already a list. Python is not a typed language, so there are no arrays. I mean the kind of array that is natively present in C.
Python is both strongly typed and dynamically typed. Which means that every value has a specific type that cannot and will not change, but also that any variable can refer to any value of any type. Similarly, every list element can refer to any type BUT we have a convention of having all list elements be of the same type. I hope that this elps.
Yes, a number of languages use the term "array", even though it's not quite technically right. Ruby and Perl also call those arrays. (You could argue that the popularity of these languages outweighs the pedantic definitions from computer scientists, though!)
This man types faster than I can run
It's all thanks to my parents forcing me when I was in high school. I promise you, everyone can learn to touch type, and you can/should learn as soon as you can!
@@ReuvenLerner Absolutely amazing skill! I beg you for some hints! I have no idea how to learn such fast touch type, how and where to start.
@@symfoniatragic Thanks; I learned when I was in high school, and it was one of the best things I ever learned. I *hated* it when I had to learn, but I super appreciate it now. I'll try to do a video about tyouch typingn in the future!
that i mean arrays in Java or C are faster to iterate over when using primitive data types that is why Java has Int and Integer Object when building an Integer Object array its almost the same as python lists with set length. But when just using a primitive type Array the data will be stored in memory directly following each other and adding the size of your datatype to the array pointer will return the next data point for example Int64 add 64 to your pointer and there you have the pointer to the next element but with python you would have to dereference twice you increment the array pointer to get the pointer to your data. The way C implements this makes branch prediction really good because if you access one element of an Array you are likely to want to access all of them.
So the CPU can just load all of them into Cache and provide access without having cache misses. Now python might do some stuff to mittigate this but over all its gonna be a little slower.
That should also be the reason why Arrays in python are only implemented for primitive data types since otherwise lists and arrays seem to be the same.
I'd say the use case for python arrays is communicating with extension modules. If you want to pass a collection of say ints between the python code and the C code in an extension module the array.array structures allow this quite easily, because the data is already stored as a C array and can be used without complicated copying in the glue code.
That's a very good point! I haven't written extension modules in C or any other language, but I do remember reading/seeing that arrays make it easier to do that. Thanks for the comment!
That was exactly the reason why I have used python array as well
Fully answered! but it's still weird when I think about it. Thanks anyways. great video
Glad you enjoyed!
The array does not allow adding elements. If elements can be added, then it is already a list. Python is not a typed language, so there are no arrays. I mean the kind of array that is natively present in C.
Python is both strongly typed and dynamically typed. Which means that every value has a specific type that cannot and will not change, but also that any variable can refer to any value of any type. Similarly, every list element can refer to any type BUT we have a convention of having all list elements be of the same type. I hope that this elps.
List: Array of Pointers (Memory addresses) to Primary Data
array.Array: Array of Primary Data, where type is restricted at array object creation
I used array so often in C code which is very different from list.
Yes, they're very different -- but so many people don't realize it.
In JavaScript an array can contain any type
Paste this in your browser: Array.isArray(["bug", 1, 2]);
Yes, a number of languages use the term "array", even though it's not quite technically right. Ruby and Perl also call those arrays. (You could argue that the popularity of these languages outweighs the pedantic definitions from computer scientists, though!)
thanks!