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

Резултати

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

Пребарај: #kuindzhi

当前筛选 #kuindzhi清除筛选

## ⛰️ THE ROOF OF AFRICA: WHERE EARTH TOUCHES HEAVEN ## ⛰️ የአፈሪካ ጋራ: ምድር ሰማይ የሚመሰከርበት 🌍 КОГДА ГОРЫ КАСАЮТСЯ НЕБЕС! Simien Mountains — Ethiopia's crown jewel and UNESCO World Heritage site where ancient volcanic peaks pierce the clouds at 4,500 meters! ⛰️ 🌅 THE DRAMATIC LANDSCAPE: These jagged ridges were sculpted by millions of years of volcanic fury, creating one of Earth's most breathtaking panoramas. *Эти зубчатые вершины — самый драматичный пейзаж на планете!* *እነዚህ የተበዳደሩ አጫያዎች በዓለም ውስጥ የተሳከሩ ምብጣት ምክንያቶች ነው!* Deep gorges plunge 1,500 meters below — called "the chess pieces of the gods" by locals for their dramatic, sharp pinnacles. 🐒 UNIQUE WILDLIFE: Home to the endangered Gelada baboons — the "bleeding heart" monkeys found NOWHERE else on Earth! *Самые редкие павианы в мире живут только здесь!* *በዓለም አንደ ቦታ የሚገኙ የጋላዳ ብድንዎች እዚህ ብቻ ይገኛሉ!* These gentle giants graze the highland meadows in massive troops, living peacefully at altitudes that would leave most humans breathless. 🌟 KUINDZHI'S VISION BROUGHT TO LIFE: At sunset, these mountains transform into layers of gold and shadow — like stepping into a painting by the Russian master Arkhip Kuindzhi. Light becomes sculpture, air becomes canvas, and the soul expands infinitely. *На закате горы превращаются в живую картину Куинджи!* *በሰሙን መግረብ ጋታ አያቶች የኩይንዅጂ እሳት ይሆናሉ!* This is Ethiopia. Where nature paints with light and shadows, where time stands still, and where every breath feels sacred. 📸Swipe through: Photo 1-2: Real dramatic vistas → Photo 3: Algorithmic art in Kuindzhi style! *Фото 1-2: Реальные панорамы → Фото 3: Алгоритмическое искусство!* #SimienMountains#የሲሚኤንአያቶች#Ethiopia#ኢትዮጵያ#UNESCO#Kuindzhi#AlgorithmicArt#የአልገሪዝምእሳት#EthiopianHighlands#የኢትዮጵያአያቶች#MountainMagic 🇪🇹@ethiopia

## 🐺 THE SWEET SECRET OF ETHIOPIAN WOLF: NATURE'S RAREST CANID ## 🐺 የኢትዮጵያ ዝዕብ መስጠር: የተፈጥሮ የታታ እንሰሳ 🌸 КОГДА ХИЩНИК ЛЮБИТ СЛАДКОЕ! Meet Africa's rarest canid — the Ethiopian wolf. Only 500 individuals remain in the world, found NOWHERE else on planet Earth! 🌍 🏞️ THE EXCLUSIVE HABITAT: These magnificent predators live only in Ethiopia's highlands — Simien and Bale Mountains — where their reddish-golden fur glows like fire in the sunset light. *Рыже-золотая шерсть сияет как огонь на закате!* *የፊያ-ዋሪራው ምስዚው በሰሙን መግረብ በክትት እናት ይችጋል!* 🌸 THE SWEET DISCOVERY: Here's the secret scientists discovered — these apex predators have a SWEET TOOTH! Ethiopian wolves visit giant Red-hot Poker flowers (Kniphofia) to lick nectar for glucose energy in the thin highland air. *Учёные открыли: волки любят сладкий нектар!* *የሳይንስ ልምዓን ገለጫቹ: ዝዕቦች ሳኳ ከማቃ ይፈልጋሉ!* Imagine: a fierce hunter perfectly adapted to chase rodents at 4,000 meters altitude, pausing gently to lick sweet nectar from vibrant orange blooms. *Представьте: свирепый охотник нежно слизывает нектар с цветка!* Nature's poetry! ⚡ WHY THIS MATTERS: This behavior reveals the deep connection between predator and plant, hunter and flower. *Глубокая связь между хищником и растением!* *በእንሰሳ እና ዕጥዋት ማካከል የተፈጥሮ አጋጣጠን!* In Ethiopia, even wolves understand the sweetness of life. 🌅 KUINDZHI'S GOLDEN HOUR: At sunset, when light paints everything in warm tones, the Ethiopian wolf becomes a living artwork — like stepping into Kuindzhi's masterpiece where every shadow tells an ancient story. *В золотой час волк становится живой картиной!* *በዋሪራ ሰዓት ዝዕብ የተገለጻ የእሳት እን፤ቤቶች ይሆናል!* 📸 Swipe through: Photo 1: Wolf licking nectar (TONGUE VISIBLE!) → Photo 2: Artistic shot → Photo 3: Kuindzhi algorithmic art! *Фото 1: Волк с языком! → Фото 3: Алгоритмическое искусство!* #EthiopianWolf#የኢትዮጵያዝዕብ#Ethiopia#ኢትዮጵያ#EndangeredSpecies#የተዘገጡእንሰሳቶች#Wildlife#የብራት#Nectar#Kuindzhi#AlgorithmicArt#የአልገሪዝምእሳት#RareBeauty 🇪🇹@ethiopia

# 💦 TIS ISSAT: THE SMOKING WATER OF BLUE NILE ## 💦 ጥስ ኢሳት: የገባዊ አባይ ተሥታት ውሃ 🌊 КОГДА ВОДА ПОЁТ И ДЫШИТ! Blue Nile Falls — one of Africa's most powerful waterfalls! Locals call it "Tis Issat" meaning "Smoking Water" because of the massive spray that creates a permanent rainbow in the mist. 🌈 ⚡ THE UNSTOPPABLE POWER: During rainy season, over 400,000 cubic meters of water PER SECOND crash down 45 meters! The thunderous roar echoes for kilometers. *400,000 кубометров воды В СЕКУНДУ!* *በሳምንት 400,000 ኩብ ሜትር ውሃ የሚወርድ!* The earth trembles, the air fills with mist, and nature reminds us of her eternal strength. 🌈 THE RAINBOW MAGIC: A perpetual rainbow dances in the waterfall's mist throughout the day when sunlight breaks through. *Вечная радуга танцует в тумане!* *የመቀጠል ቋቅደም በመታት ውስጥ ይየጫል!* Nature's own light show, playing since the beginning of time! 🏞️ 4,000 YEARS OF HISTORY: These falls have witnessed Ethiopian civilization since ancient times. Emperors stood here, poets wrote verses, lovers made eternal promises. *Вода падает уже 4000 лет, равнодушная к времени!* *የውሃ አባይ ከታና ኦዛ እስከ ማዲተራኔአን በመወረድ ይጋዝ!* The water keeps falling, eternal in its journey from Lake Tana to the Mediterranean Sea. ☀️ KUINDZHI'S VISION ALIVE: When dramatic light breaks through storm clouds — god rays illuminating the sacred waters — it's like witnessing Kuindzhi's masterpiece come to life. The Russian master painted light as sculpture; here, nature does the same! *Божественные лучи как в картине Куинджи!* *የእገዚአብሄር ልመዶች እናት ኩይንዅጂ እሳት!* This waterfall doesn't just fall — it sings, it breathes, it lives. It's the heartbeat of the Blue Nile, the pulse of Ethiopia! 💙 📸Swipe through: Photo 1-2: Real waterfall power → Photo 3: Kuindzhi algorithmic art with god rays! *Фото 1-2: Реальная мощь → Фото 3: Алгоритмическое искусство!* #BlueNileFalls#የገባዊአባይጠራጣ#TisIssat#ጥስኢሳት#Ethiopia#ኢትዮጵያ#Waterfall#የውሃአባይ#Rainbow#Kuindzhi#AlgorithmicArt#የአልገሪዝምእሳት#NaturalWonder#የተፈጥሮአግጣጠን 🇪🇹@ethiopia