2

In arrays the values of arrays stored in consecutive memory locations, ao I have to ask that is python list values saved in consecutive memory locations like arrays?

Usman Developer
  • 558
  • 5
  • 24
  • 4
    How the list is stored in memory is an implementation detail that you can't rely on. – chepner Nov 15 '18 at 16:19
  • Check https://stackoverflow.com/questions/3917574/how-is-pythons-list-implemented – migron Nov 15 '18 at 16:22
  • 1
    The list stores pointers to values elsewhere in memory. – hpaulj Nov 15 '18 at 16:37
  • @hpaulj thanks but these pointers are consecutive or not (I have to ask this actually)... – Usman Developer Nov 15 '18 at 16:42
  • Discussions that I've seen say that the pointer buffer is contiguous. When it runs out of growth room it copies those pointers to a new larger buffer. But that's an implementation detail. Your use of 'consecutive' might mean something different. – hpaulj Nov 15 '18 at 16:53
  • If you're looking for contiguous storage, have a look at [numpy.array](https://docs.scipy.org/doc/numpy-1.15.1/reference/generated/numpy.array.html) – s3cur3 Nov 15 '18 at 18:04

0 Answers0