Do you lose computational time when you put the iterable on the right counterintuitively like that?
Or its ideal in most situations?
Hi Panagiotis!
Thanks for reaching out.
In many cases, list comprehensions can be more efficient and faster compared to traditional loops. However, it's important to note that the actual performance of list comprehensions depends on various factors, including the complexity of the expression and the size of the data. In some cases, using nested or complex expressions within list comprehensions can lead to decreased performance.
In general, for most straightforward and simple operations, list comprehensions offer an efficient and concise way to create lists in Python. However, for more complex or computation-heavy tasks, it's recommended to identify the most efficient solution for your specific use case.
Hope this helps.
Best,
Ivan
@Ivan Manov
the video gives the direct opposite answer: that the list comprehensions "generally require more memory and run more slowly".
Though the video does not specify compared to what, is it safe to assume that to the nested loops?
Thus, which is true, in the end?