#2 Optimization | List vs Tuple Memory Usage Comparison using sys module | Python for Beginners

Опубликовано: 03 Апрель 2023
на канале: Learn with Yasir
627
27

‪@yasirbhutta‬ #yasirbhutta
In this Python code, we are comparing the size of a list and a tuple using the sys.getsizeof() method.

First, we define a list called my_list and a tuple called my_tuple with the same five elements.

Then, we use the print() function to output the size of my_list and my_tuple in bytes using sys.getsizeof() method.

The output will show the memory size occupied by both the list and the tuple.

This code is useful for demonstrating the difference in memory usage between lists and tuples in Python. It is important to note that tuples are generally more memory-efficient than lists due to their immutable nature.

If you enjoyed this video, please give it a thumbs up 👍and leave a comment 💬 below. Don't forget to subscribe 🔔to my channel for more Python tutorials like this one.

Python Video Training: https://yasirbhutta.github.io/python/...

YouTube Playlists:

Python made easy with YB - join our Beginner's Playlist today!: https://bit.ly/3z9744q

Learn Microsoft Excel:    • Excel 365 Tutorial for Beginners [latest v...  

You can also follow me on:

Website: https://yasirbhutta.github.io/
Facebook:   / yasirbhutta786  
YouTube:   / @yasirbhutta  
Twitter:   / yasirbhutta  

Thanks for watching! 🙏**

#codingshorts #coding #pythonprogramming #pythonbasics #codingshortvideo #yasirbhutta #yasirbhutta #python #pythontutorial #codinglife


На этой странице сайта вы можете посмотреть видео онлайн #2 Optimization | List vs Tuple Memory Usage Comparison using sys module | Python for Beginners длительностью часов минут секунд в хорошем качестве, которое загрузил пользователь Learn with Yasir 03 Апрель 2023, поделитесь ссылкой с друзьями и знакомыми, на youtube это видео уже посмотрели 627 раз и оно понравилось 27 зрителям. Приятного просмотра!