dynamic arrays and amortization when creating low-level array in computer systemthe precise size of that array must be explicitly declared in order for the system to properly allocate consecutive piece of memory for its storage for examplefigure displays an array of bytes that might be stored in memory locations through figure an array of bytes allocated in memory locations through because the system might dedicate neighboring memory locations to store other datathe capacity of an array cannot trivially be increased by expanding into subsequent cells in the context of representing python tuple or str instancethis constraint is no problem instances of those classes are immutableso the correct size for an underlying array can be fixed when the object is instantiated python' list class presents more interesting abstraction although list has particular length when constructedthe class allows us to add elements to the listwith no apparent limit on the overall capacity of the list to provide this abstractionpython relies on an algorithmic sleight of hand known as dynamic array the first key to providing the semantics of dynamic array is that list instance maintains an underlying array that often has greater capacity than the current length of the list for examplewhile user may have created list with five elementsthe system may have reserved an underlying array capable of storing eight object references (rather than only fivethis extra capacity makes it easy to append new element to the list by using the next available cell of the array if user continues to append elements to listany reserved capacity will eventually be exhausted in that casethe class requests newlarger array from the systemand initializes the new array so that its prefix matches that of the existing smaller array at that point in timethe old array is no longer neededso it is reclaimed by the system intuitivelythis strategy is much like that of the hermit crabwhich moves into larger shell when it outgrows its previous one we give empirical evidence that python' list class is based upon such strategy the source code for our experiment is displayed in code fragment and sample output of that program is given in code fragment we rely on function named getsizeof that is available from the sys module this function reports the number of bytes that are being used to store an object in python for listit reports the number of bytes devoted to the array and other instance variables of the listbut not any space devoted to elements referenced by the list