data structuresalgorithmsand code simplification item description returns the number of occurrences of in appends to the end of array can be an array or an iterable object whose elements are the same type as in fromfile(fnreads items (in binary formatfrom the file object and appends to the end of the array must be file object raises eoferror if fewer than items can be read fromlist(listappends items from list to the end of the array list can be any iterable object fromstring(sappends items from string swhere is interpreted as string of binary values--same as would have been read using fromfile( index(xreturns the index of the first occurrence of in raises valueerror if not found insert(ixinserts before position pop([ ]removes item from the array and returns it if is omittedthe last element is removed remove(xremoves the first occurrence of from the array raises valueerror if not found reverse(reverses the order of the array tofile(fwrites all items to file data is saved in native binary format tolist(converts the array to an ordinary list of values tostring(converts to string of binary data--the same data as would be written using tofile( tounicode(converts the array to unicode string raises valueerror if the array is not of type 'ua count(xa extend(bwhen items are inserted into an arraya typeerror exception is generated if the type of the item doesn' match the type used to create the array the array module is useful if you need to have space-efficient storage for lists of data and you know that all items in the list are going to be the same type for examplestoring million integers in list requires about mb of memory whereas an array of million integers requires only mb despite this space savingsnone of the basic operations on an array tend to be faster than their list counterparts--in factthey may be slower in performing calculations with arraysyou will want to be careful with operations that create lists for exampleusing list comprehension on an array will convert the entire array into listdefeating any space-saving benefit better way to handle this is to create new arrays using generator expressions for examplea array array(" "[ , , , , ] array array( typecode( * for in )create new array from because the point of using an array is to save spaceit may be more desirable to perform "in-placeoperations an efficient way to do this is with code that uses enumerate()like thisa array array(" "[ , , , , ]for ix in enumerate( ) [ * lib fl ff