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

Резултати

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

Пребарај: #proudlyethiopian

当前筛选 #proudlyethiopian清除筛选

🌍 DID YOU KNOW THE WORLD USES ETHIOPIAN TECHNOLOGY? 🌍 አለም የኢትዮጵያ ቴክኖሎጂ እንደምትጠቀም ያውቃሉ? Every time someone mentions "Abyssinian well" - they're honoring Ethiopia! "የአቢሲኒያ ጉድጓድ" ሲባል - ለኢትዮጵያ ክብር እየተሰጠ ነው! 🤯 MIND = BLOWN! While you were thinking Ethiopia only gave the world coffee, we were out here revolutionizing WATER ACCESS! 💧 THE ABYSSINIAN WELL: ✅ Simple, genius technology for accessing groundwater ✅ Can be installed by hand - no heavy machinery needed ✅ Works in rural areas where big drilling rigs can't reach ✅ Cost-effective solution used WORLDWIDE ✅ Named after our ancient homeland - ABYSSINIA! 🇪🇹 🌟 FROM ANCIENT WISDOM TO MODERN IMPACT: Our ancestors looked at the problem of water access and said: "Hold my tej, we got this!" And created a solution so brilliant that THE ENTIRE WORLD still calls it by our name. 🚀 ETHIOPIA'S GIFT TO HUMANITY: ☕Coffee - We gave you your morning energy 💧Abyssinian Wells - We gave you access to clean water 📅13-month calendar - We gave you a better way to count time ✍️Ancient scripts - We preserved knowledge when others couldn't write 🔥 PLOT TWIST: While everyone talks about "developing nations," Ethiopia has been developing SOLUTIONS that the whole world adopts! 🌍 EVERY DROP OF WATER from an Abyssinian well is a reminder: ETHIOPIAN INNOVATION FLOWS THROUGH THE WORLD! 💪 👑 RESPECT THE LEGACY. RESPECT THE INNOVATION. 👑 ወቅቱን አክብሩ። ፈጠራውን አክብሩ። *Next time you hear "Abyssinian well" - remember where genius comes from* 🇪🇹 #EthiopianInnovation#የኢትዮጵያፈጠራ#AbyssinianWell#WaterTechnology#EthiopianLegacy#InnovationNation#ProudlyEthiopian#TechHistory#ኢትዮጵያላይፍ#RespectTheOrigin

🔥 FROM VILLAGE TO VOGUE: HOW ETHIOPIA REDEFINES FASHION 🔥 ከገጠር እስከ ቩግ: ኢትዮጵያ ፋሽንን እንዴት እንደምትገለጽ 🌟 КОГДА ТРАДИЦИЯ ВСТРЕЧАЕТ РЕВОЛЮЦИЮ! Ethiopian youth aren't just wearing clothes - they're making STATEMENTS! 💫 👑 THE NEW ETHIOPIAN FASHION WAVE: 🎨 HABESHA KEMIS GOES GLOBAL: - Traditional white cotton dresses with colorful borders → Modern streetwear inspiration - International runways now feature Ethiopian-inspired designs - What grandmothers wore to church, Gen Z wears to fashion week! 💎 ETHIOPIAN FASHION BRANDS TAKING OVER: 🌟YEFIKIR Design - Contemporary takes on traditional silhouettes 🌟Mahlet Afework Designs - Haute couture meets heritage 🌟ENDA Ethiopian - Athletic wear inspired by Ethiopian runners 🌟Mafi Mafi - Luxury accessories with cultural storytelling 🌟Solerebels - Eco-friendly footwear that conquered the world 🔥 THE SWAG FORMULA: ✨ Ancient patterns + Modern cuts = FIRE ✨ Handwoven fabrics + Contemporary styling = ICONIC ✨ Cultural pride + Global appeal = UNSTOPPABLE 📸 STREET STYLE ADDIS: - Netela shawls worn as haute couture wraps - Traditional jewelry mixed with designer pieces - Coffee ceremony dresses styled for Instagram - Berbere-colored accessories (that spice aesthetic!) 🌶️ 🚀 PLOT TWIST: While the world chases fast fashion, Ethiopia creates TIMELESS pieces that tell 3000-year-old stories! 💪 YOUNG ETHIOPIANS SAY: "We don't follow trends - WE SET THEM!" "እኛ ዝንባሌዎችን አንከተልም - እኛ እናዘጋጃለን!" 👗 WHEN YOU WEAR ETHIOPIAN: You're not just dressed - you're carrying HISTORY, CULTURE, and FUTURE in one look! *Ethiopian fashion: Where every thread tells a story* 🧵✨ #EthiopianFashion#የኢትዮጵያፋሽን#HabeshaStyle#EthiopianDesigners#AfricanFashion#FashionRevolution#TraditionalMeetsModern#EthiopianBrands#ኢትዮጵያላይፍስታይል#ProudlyEthiopian