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

Резултати

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

Пребарај: #nusadua

当前筛选 #nusadua清除筛选
Bali News

@balinews · Post #78 · 06.06.2024 г., 05:50

⛳International Golf Day on 15 June 📍 Marriott International Corporation is holding its annual International Charity Golf Day in Bali. This year's event will be held on 15 June at the National Golf Club in Nusa Dua. 🏌️‍♀️ Everyone can join this elite and expensive game, not only through participation in tournaments, but also during the evening programme, which the organisers announce as a kind of networking. 🎷 The festive evening will take place at the Westin Resort Nusa Dua at 18:30 the same day. Everyone is welcome to attend. The dinner will feature a buffet of international cuisine with beer, wine and soft drinks. In addition, guests can expect door prizes, auctions, and an entertainment programme with live music. @BaliNews #wheretogo#events#NusaDua

Bali News

@balinews · Post #173 · 16.09.2024 г., 10:01

🎾Tennis in Bali: Nusa Dua opens clubhouse for ATP level tournaments 📍 The Bali Golf and Racket Club has opened in Nusa Dua, ready to host ATP tournaments in the future. It is the newest sports complex located in the heart of one of Bali's most prestigious resort areas, The Nusa Dua, which is famous for its five-star hotels and unique infrastructure. 🏆 The club was the first of its kind on the entire island. With its appearance, Bali acquires the status of not only a paradise island, but also a center for international tennis tournaments and sports tourism. @BaliNews #goodnews#sport#NusaDua

Bali News

@balinews · Post #410 · 15.05.2025 г., 11:25

🎶TGIF 2025 music festival will return to Bali in May The event promises to be one of the highlights of the music season in Bali. 📆 May 24-25 📍 At a new venue in Port of Benoa ℹ️ In addition to concerts and live music, guests can expect food courts from local businesses, photo zones, interactive entertainment and relaxation areas. Parking and shuttles to shuttle guests are available for convenience. 🎫 Tickets are on sale now: one-day, two-day and VIP packages are available on the official website from Rp 150.000. #events#festivals#wheretogo#NusaDua@BaliNews

Bali News

@balinews · Post #459 · 10.07.2025 г., 13:33

🛎The first Waldorf Astoria hotel opens in Bali: second attempt 📰 The Hilton hotel group is expanding its presence in Bali. Waldorf Astoria Bali will be located between the Hilton and Kempinski hotels in Nusa Dua, 14.5 km from Ngurah Rai International Airport. The hotel is scheduled to open in late 2027. 🏨 Waldorf Astoria Bali will include 71 spacious villas and 68 guest suites, as well as the standard infrastructure for a chain hotel — restaurants, a spa, a fitness center, children's entertainment, and event rooms. ℹ️ Waldorf Astoria had already announced the opening of its hotel in Bali in 2014. At that time, the location was chosen near Pandawa Beach in the south of the island. The opening was planned for 2027, but something went wrong. The massive concrete unfinished building can still be seen on the cliff to the left of the entrance to Pandawa Beach. #places#realestate#development#NusaDua@BaliNews

Bali News

@balinews · Post #338 · 01.03.2025 г., 12:26

🚤New Bali water taxi service launches for tourists 📰 A new marine transportation service, Bali Marine Water Taxi, has been launched in the popular resort area of Benoa (Nusa Dua) in Bali. 📍 The tourist cab service connects the seaports of Tanjung Benoa, Serangan and Pedungan (South Denpasar). 35 minutes. That’s all it takes. No traffic, no stress - just ocean views and open horizons. Uluwatu is calling. 👍 This is just one of the many sea routes Bali plans to develop in the coming months. @BaliNews #goodnews#places#services#transport#tourism#NusaDua

Bali News

@balinews · Post #120 · 19.07.2024 г., 11:02

🛣Details about the construction of a district road in Bukit District authorities are set to solve the road issue in Uluwatu by laying a new district road. Construction of the first section from Siligita village to Sawangan in Nusa Dua district has already started. The original idea was to extend the toll road, which now runs from the airport to Nusa Dua, all the way to Uluwatu. Right now, traffic on the main road jl. Uluwatu is difficult because it is both a hub of commerce and the main thoroughfare of the area, used by everyone from locals to construction vehicles and tour buses. The land acquisition budget for 2024 will be $16 million, with the next one already promised to increase to $19 million. According to an insider in Bali's land office, all consideration of new housing development in the green zone on Bukit is now halted just in time for the land acquisition for the new roads. @BaliNews #roads#roads#authorities#Bukit#Uluwatu#NusaDua