Member-only story
I have been using Python’s numerical library since I have been studying data science for over two years now. When studying the numpy, I learned that the library is fast.
I had also read that numpy arrays are faster than lists. The reason for this is because numpy arrays are stored in one continuous place in memory unlike lists, so processes can access and manipulate them very efficiently. This behaviour is called locality of reference in computer science and is the main reason why numpy arrays are faster than lists. I decided to put the theory to the test and see if what I had read is actually true.
I created a program in Google Colab, which is a free online Jupyter Notebook hosted by Google. Google Colab is a great platform to use when carrying out data science projects in Python because all of the coding is done on the web browser and no software needs to be installed on a computer. The only major flaw in this program that I have found is the fact that it does not have an adequate undo function, so care needs to be taken not to accidentally overwrite or delete valuable code.
I created two cells to carry out this test.
In the first cell, I imported the two libraries that I would need, being numpy and sys. Numpy is used to create numpy arrays and sys is used to manipulate…