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

Резултати

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

Пребарај: #urbanplanning

当前筛选 #urbanplanning清除筛选
Interesting Planet 🌍

@interesting_planet_facts · Post #1266 · 01.02.2026 г., 12:11

🌎 The ancient city of Mohenjo-daro in present-day Pakistan was part of the Indus Valley Civilization around 2500 BCE. It featured grid-planned streets, advanced drainage, brick houses, and a massive central bath. Mohenjo-daro was mysteriously abandoned by about 1900 BCE without clear evidence of war or disaster. ✨ #archaeology⚡#IndusValley⚡#urbanplanning 👉subscribe Interesting Planet 👉more Channels ​

Amazing Geography 🌍

@amazingeo · Post #552 · 02.01.2026 г., 20:31

🌍 Paris is creating "urban forests" by planting patches of dense woodland in city plazas and streets. These mini-forests lower summer temperatures and boost urban biodiversity. ✨ #urbanplanning⚡#sustainability⚡#biodiversity⚡#geography⚡#nature⚡#earth 👉subscribe Amazing Geography 👉more Channels ​

MyGov Newsdesk

@mygovcoronanewsdesk · Post #12208 · 01.03.2023 г., 09:20

भारत में अर्बन डेवलेपमेंट के दो प्रमुख पक्ष है- नए शहरों का विकास और पुराने शहरों में पुरानी व्यवस्थाओं का आधुनिकीकरणः प्रधानमंत्री #urbanplanning#budget2023#unionbudget2023 https://youtu.be/CEiyK3D4O-k

Amazing Geography 🌍

@amazingeo · Post #594 · 26.01.2026 г., 12:31

🌍 In Stockholm, almost every resident lives within 300 meters of green space thanks to city planning that weaves parks and nature into neighborhoods—boosting health and local biodiversity. ✨ #urbanplanning⚡#sustainability⚡#cities⚡#geography⚡#nature⚡#earth 👉subscribe Amazing Geography 👉more Channels ​

Amazing Geography 🌍

@amazingeo · Post #138 · 29.08.2025 г., 13:12

🌍 Curitiba, Brazil transformed bus transit by designing special lanes just for buses, boosting speed and cutting traffic. This inspired cities worldwide to rethink sustainable urban transport. ✨ #urbanplanning⚡#sustainability⚡#transport⚡#geography⚡#nature⚡#earth 👉subscribe Amazing Geography🌍 ​

Amazing Geography 🌍

@amazingeo · Post #406 · 23.10.2025 г., 12:31

🌍 Copenhagen aims to become the world’s first carbon-neutral capital by 2025, using bike highways, wind energy, and smart urban drainage to cut emissions while keeping the city livable. ✨ #urbanplanning⚡#sustainability⚡#environment⚡#geography⚡#nature⚡#earth 👉subscribe Amazing Geography 👉more Channels ​

Amazing Geography 🌍

@amazingeo · Post #482 · 28.11.2025 г., 20:31

🌍 Singapore’s “park connector” network links a growing web of green trails and corridors across the city, letting wildlife and people travel between parks, even in dense urban neighborhoods. ✨ #urbanplanning⚡#sustainability⚡#wildlife⚡#geography⚡#nature⚡#earth 👉subscribe Amazing Geography 👉more Channels ​

Amazing Geography 🌍

@amazingeo · Post #631 · 14.02.2026 г., 12:31

🌍 Some cities recycle wastewater to irrigate parks, saving drinking water for people. This system helps lower water use and keeps urban landscapes greener even in dry climates. ✨ #urbanplanning⚡#sustainability⚡#water⚡#geography⚡#nature⚡#earth 👉subscribe Amazing Geography 👉more Channels ​

Amazing Geography 🌍

@amazingeo · Post #291 · 24.09.2025 г., 15:31

🌍 In Freiburg, Germany, whole neighborhoods are designed with solar panels, car-free streets, and green spaces. These urban plans cut energy use and make city life healthier and more sustainable. ✨ #urbanplanning⚡#sustainability⚡#energy⚡#geography⚡#nature⚡#earth 👉subscribe Amazing Geography 👉more Channels ​

Amazing Geography 🌍

@amazingeo · Post #250 · 17.09.2025 г., 00:12

🌍 Singapore manages stormwater with a vast network of rooftop gardens, ponds, and clever drainage, helping prevent floods while cooling the city and supporting urban wildlife. ✨ #urbanplanning⚡#sustainability⚡#Singapore⚡#geography⚡#nature⚡#earth 👉subscribe Amazing Geography🌍 ​

Mappasaurus Official Channel

@mappasaurusofficial · Post #298 · 06.04.2025 г., 15:13

🍀Build Sustainable Cities with Mappasaurus!🌐 🪄Empower Eco-Friendly Urban Planning: ⏺Optimize Resources: Utilize our maps for efficient resource allocation and green urban projects. ⏺Smart Routing: Reduce emissions with AI-driven routes that minimize travel times and fuel usage. 🦖Why MappaSaurus❓ ⏺Enhance Urban Resilience: Support sustainable development that adapts to environmental challenges. ⏺Encourage Community Involvement: Use transparent mapping to foster public participation in urban planning. ⚔️Shape Greener, Smarter Cities with Us ⏺ See how Mappasaurus leads the way in eco-friendly urban planning. 💯#Mappasaurus#SustainableCities#UrbanPlanning#EcoFriendly#SmartCities

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