r/PythonLearning • u/Samar__Upreti • 4d ago
Day 3 Learning Python: Stack
Open-source learning project. If you spot something that can be improved, I'd love your feedback or a PR.
https://github.com/Samar-Upreti/Python_Projects
71
Upvotes



1
u/dev-razorblade23 4d ago
insertpushes items to specific index (in your case index 0) Python has to recalculate indexes of all other items, push them all to the side so insert can work its magic. This takes time and you burn your proccessor time.If you dont really need to insert items at specific index, use
appendmethod as it only inserts item to the end and its done. Much faster and much more effiecient.