

- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
What is the difference between a python list and an array?
Basically, Python lists are very flexible and can hold completely heterogeneous, arbitrary data, and they can be appended to very efficiently, in amortized constant time. If you need to shrink and grow your array time-efficiently and without hassle, they are the way to go. But they use a lot more space than C arrays.
The array.array type, on the other hand, is just a thin wrapper on C arrays. It can hold only homogeneous data, all of the same type, and so it uses only sizeof(one object) * length bytes of memory.
So a list can be like: [1, 'a', [1, 2], 'string']
But an array can only contain things of the same type: [1, 2, 3, 4]
- Related Questions & Answers
- What is the difference between a list and an array in C#?
- What is the difference between a python list and a tuple?
- What is the difference between a simulator and an emulator?
- Difference Between Array and Linked List
- What is the difference between list and dictionary in C#?
- What is the difference between List and IList in C#?
- What is the difference between a python module and a python package?
- What is the difference between a python tuple and a dictionary?
- What is the difference between a kernel and an operating system?
- What is the difference between array_merge and array + array in PHP?
- What is the difference between working of append and + operator in a list in Python?
- What is the difference between an island and the continent?
- What is the difference between = and == operators in Python?
- What is the difference between an acronym and abbr tags?
- What is the difference between a class and an object in C#?
Advertisements