it depends what elements are, but in most cases 5000 items is not that much and should not crash python. of course it also depend on your machine RAM. Maybe you are doing something wrong.
also, depending on how you create your list, you could create generator/iterator and iterate over it one element at a time without creating the entire list in memory
can you provide more info on how you create the list/what its elements are, etc. maybe provide sample data
also, depending on how you create your list, you could create generator/iterator and iterate over it one element at a time without creating the entire list in memory
can you provide more info on how you create the list/what its elements are, etc. maybe provide sample data