Posted in 2024
Reorder items in a list
- 13 December 2024
Lists in Python are ordered collections of items. You can reorder the items in a list using the sort method or by manually moving items around in the list. So let’s start with an example of how you can print an unsorted list as items at index 2 and 3 are not in order.
Speeding up functions in Python
- 20 January 2024
Python’s versatility and ease of use make it a popular choice for a wide range of programming tasks. However, performance can sometimes be a concern, especially when working with large data sets or computationally intensive tasks. Repetitive calculations can be a particular problem, but Python provides a number of tools to help speed up these functions. One way is to use the functools.cache
decorator to cache the results of a function which was introduced in Python 3.9. This can be used to avoid repeating calculations, and can significantly speed up the execution of a function.