TGTGInsighttelegram intelligenceLIVE / telegram public index
← Python Заметки

TGINSIGHT SIMILAR POSTS

Најди сличен содржај

Изворен канал @pythonotes · Post #32 · 7 фев.

Скорее всего уже слышали, что складывать строки через + это плохая практика. Падение производительности, и всё такое. Без лишних слов, давайте измерять: from timeit import timeit def t1(): # складываем 10 строк через + из переменной t = 'text' for _ in range(1000): s = t + t + t + t + t + t + t + t + t def t2(): # склеиваем список строк через метод join arr = ['text'] * 10 for _ in range(1000): s = ''.join(arr) def t3(): # складываем через + но не из переменной а непосредственно инлайн объекты for _ in range(1000): s = 'text' + 'text' + 'text' + ... # всего 10 раз Теперь каждую строку склейки запустим по 10М раз >>> timeit(t1, number=10000) 0.21951690399964718 >>> timeit(t2, number=10000) 1.4978306379998685 >>> timeit(t3, number=10000) 0.2213820789993406 Хм, а нам говорили что через "+" это плохо и медленно ))) 😁 Тут стоит учитывать, что речь идёт о склейке множества длинных строк. Давайте изменим условия: def t4(): t = 'text'*100 for _ in range(1000): s = t + t + t + t + t + t + t + t + t def t5(): arr = ['text'*100] * 10 for _ in range(1000): s = ''.join(arr) def t6(): for _ in range(1000): s = 'text'*100 + 'text'*100 + ... # всего 10 раз >>> timeit(t4, number=10000) 12.795130728000004 >>> timeit(t5, number=10000) 2.642637542999182 >>> timeit(t6, number=10000) 0.2184546610005782 Вот, уже другой разговор, сразу видна разница, в среднем в 6 раз. Но погодите, почему последний тест t6() по скорости такой же как и t3()? Ведь строки теперь в 100 раз длиннее! Это вопросы оптимизации кода, какие простые изменения ускоряют или замедляют выполнение программы. Мы столкнулись с примером обхода обращения к переменной. Например, именно так работает директива #define в С++, во время компиляции подставляя значение переменной вместо ссылки на неё. В Python это тоже работает, но часто ли вы сможете встретить такой способ работы со строками? К сожалению, способ почти только теоретический. В целом, тесты показали то, что мы хотели. Делаем выводы самостоятельно. Полный листинг 🌍 #tricks

Резултати

Пронајдени 41 слични објави

Пребарај: #iceland

当前筛选 #iceland清除筛选
International Geographic

@internationalgeographic · Post #5792 · 03.07.2025 г., 09:44

#Iceland🇮🇸 A special place in Iceland is considered to be the black beach. It was here that such cult movies as "The Lord of the Rings", "Game of Thrones" and "Star Wars" were filmed. The black beach was formed as a result of volcanic activity. This event happened many years ago

Hashtags

International Geographic

@internationalgeographic · Post #5448 · 24.02.2025 г., 00:26

#Iceland, Gudlfoss 🇮🇸 Gyudlfoss is a waterfall in Iceland, in the Syudurland region. The depth of the waterfall to the place of water falling in the valley is about 70 meters. The Güdlfoss itself consists of two steps - 21 meters and 11 meters high, dumped to each other at an angle of 90 °. It is considered one of the most beautiful places in Iceland and is the most visited tourists.

Hashtags

Voyage.Travel.Tourism

@VOYAGE · Post #1690 · 16.03.2026 г., 13:14

🌟Breathtaking Views of Iceland! 🟠A mesmerizing landscape where a powerful waterfall meets silent green hills and dramatic clouds on the horizon. 🟠Nature here stuns with its beauty and scale, offering perfect spots for adventure seekers and photography enthusiasts. Feel the grandeur and tranquility of these magnificent landscapes! #Iceland | @voyage

Hashtags

Voyage.Travel.Tourism

@VOYAGE · Post #1612 · 30.11.2025 г., 13:14

🗺 Iceland 🇮🇸 Following a recent volcanic eruption, the main highway to the Icelandic town of Grindavík is now impassable, and the surrounding area is covered in lava for several kilometers. #Iceland | @voyage

Hashtags

Voyage.Travel.Tourism

@VOYAGE · Post #1609 · 27.11.2025 г., 13:14

Iceland🇮🇸 🟠A canyon located in the Jokuldalur Valley, Iceland. 🟠It is famous for its columnar basalt formations and blue-green water. #Iceland | @voyage

Hashtags

Voyage.Travel.Tourism

@VOYAGE · Post #1541 · 25.08.2025 г., 12:14

Iceland🇮🇸 🟠A canyon located in the Jokuldalur Valley, Iceland. 🟠It is famous for its columnar basalt formations and blue-green water. #Iceland | @voyage

Hashtags

Voyage.Travel.Tourism

@VOYAGE · Post #1531 · 15.08.2025 г., 12:14

Iceland 🇮🇸 🟠After the eruption of Eldfell volcano on Heimaey Island, a stunning natural wonder emerged — a rock formation shaped like an elephant drinking from the Atlantic. 📏 📏 📏 📏 📏 📏 📏 📏 #Iceland | @voyage

Hashtags

Voyage.Travel.Tourism

@VOYAGE · Post #1525 · 09.08.2025 г., 12:14

⚡️Hallgrímskirkja – a majestic church in the heart of Reykjavík! ✨🏔️ 🟠Inside, it houses a massive pipe organ with 5,275 pipes, standing 15 meters tall and weighing 25 tons – a true musical masterpiece! 📏 📏 📏 📏 📏 📏 📏 📏 #Iceland | @voyage

Hashtags

Voyage.Travel.Tourism

@VOYAGE · Post #1386 · 11.04.2025 г., 12:14

✨ Hallgrímskirkja — the highest point in Reykjavik. 🟠Imagine a majestic church rising above the city like a guardian of time. Its unique architecture and panoramic views of Reykjavik make it a must-visit place. 📏 📏 📏 📏 📏 📏 📏 📏 #Iceland🇮🇸@voyage

Hashtags

ПретходнаСтраница 1 од 4Следна