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 слични објави

Пребарај: #accommodation

当前筛选 #accommodation清除筛选

🏨Recommended hotels for the RAREMET-2026 participants Dear participants of the RAREMET-2026 Congress! The Congress website contains information about hotels that are ready to receive you on special terms during the event. In this section you will find addresses, promo codes for reservations and their validity periods. 📌 Details are available on our website. 🗓Dates of the Congress: RAREMET-2026 will be held on May 20-22 in Moscow at the RTU MIREA. The organizer is Giredmet JSC. 📱 Subscribe to our channels: Telegram: t.me/raremet2026 MAX: max.ru/id7707072637_gos22 See you at the main forum of the rare metal industry! #RAREMET2026#RAREMET2026#hotels#accommodation#participants

🏨 ACCOMMODATION SECRETS: ETHIOPIA'S HIDDEN GEMS | ድንቅ የሆኑ የኢትዮጵያ ማረፊያ ቦታዎች 🌟 From royal palaces to mountain hideaways - discover where legends stay in the Horn of Africa. 🏨 LUXURY HOTELS | ቅንጡ ሆቴሎች • Sheraton Addis: $200-300/night, presidential suite where Obama stayed • Hyatt Regency: $150-250/night, rooftop views of Entoto Mountains • Radisson Blu: $120-200/night, modern amenities in heart of city • Four Points Sheraton: $100-180/night, business traveler favorite 🏡 TRADITIONAL GUESTHOUSES | ባህላዊ እንግዳ ማረፊያዎች • Yod Abyssinia: $60-80/night, authentic Ethiopian architecture • Taitu Hotel: $40-70/night, historic charm in Piazza district • Local family homestays: $15-30/night, genuine cultural immersion • Traditional tukuls: $25-50/night, round stone houses with thatched roofs 🏔️ ECO-LODGES & WILDERNESS | ተፈጥሮ ተስማሚ ስፍራዎች • Simien Lodge: $180-250/night, gelada monkeys at your doorstep • Buska Lodge (Omo Valley): $120-200/night, tribal cultural experience • Danakil camping: $40-80/night, sleep under Milky Way in Mars landscape • Lalibela mountain lodges: $80-150/night, rock churches views 💰 BUDGET ACCOMMODATIONS | የእርስዎን በጀት ያማከሉ ማረፊያዎች • Backpacker hostels: $8-15/night, shared dorms with Wi-Fi • Pension houses: $12-25/night, family-run, breakfast included • Government rest houses: $5-12/night, basic but clean • Church compounds: $3-8/night, unique spiritual experience 📱 BOOKING PLATFORMS & TIPS • Best platforms: Booking.com, Agoda, local Ethiopian sites • Direct booking: Often 10-20% cheaper, call hotels directly • Peak seasons: Christmas (Jan 7), Timkat (Jan 19), Meskel (Sept) • Negotiation: Always possible except peak times 💡 INSIDER SECRETS: Book mountain lodges 2+ months ahead. Many hotels accept USD directly. Traditional coffee ceremony often included. Ask for "faranji price" vs local rate. 🏆 From $3 sacred sanctuaries to $300 presidential suites - Ethiopia accommodates every dream! #EthiopiaHotels#ኢትዮጵያ#Accommodation#TravelSecrets#HiddenGems