Python list memory reallocation issue -


if using c-python or jython (in python 2.7), , list ([]) data structure, if continue add new elements, there memory reallocation issue how java arraylist have (since java arraylist requires continuous memory space, if current pre-allocated space full, needs re-allocate new larger continuous large memory space, , move existing elements new allocated space)?

http://grepcode.com/file/repository.grepcode.com/java/root/jdk/openjdk/6-b14/java/util/arraylist.java#arraylist.ensurecapacity%28int%29

regards, lin

internally python lists array of pointers mentioned hpaulj

the next question how can extend array in c explained in answer. explains can done using realloc function in c.

this lead me in behavior of realloc mentions

the function may move memory block new location (whose address returned function).

from understanding array object extended if contiguous memory available, else memory block (containing array object not list object) copied newly allocated memory block greater size.

this understanding, corrections welcome if wrong.


Comments

Popular posts from this blog

asynchronous - C# WinSCP .NET assembly: How to upload multiple files asynchronously -

aws api gateway - SerializationException in posting new Records via Dynamodb Proxy Service in API -

asp.net - Problems sending emails from forum -