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

Резултати

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

Пребарај: #v12

当前筛选 #v12清除筛选
РУСБИЗНЕСАВТО🚜🚌

@rbauto_ru · Post #4257 · 20.08.2025 г., 11:30

👍Только для гостей нашего стенда LIVE демонстрация и полный разбор возможностей V12 и V12 Pro ➡️Регистрируйтесь на выставку с промокодом RBA2025 для бесплатного входа! #Русбизнесавто#Higer#AutoBusExpo#V12#V12Pro

Auto Life

@revheadcrypto · Post #269 · 08.08.2024 г., 15:50

🚗✨Introducing the Nilu Supercar by Alexander Selipanov!🔥 Designed for true driving enthusiasts, the Nilu is a masterpiece that strips away unnecessary electronics to deliver pure driving pleasure. 🏁💨 🔩Powerful Performance: Equipped with a breathtaking atmospheric V12 engine producing 1070 hp, paired with a 7-speed manual transmission. This beast can reach a top speed of 400 km/h and accelerate from 0 to 100 km/h in under 3 seconds! ⚡️ ⚙️Cutting-Edge Engineering: Built on a carbon fiber monocoque with tubular subframes, featuring fully independent pushrod suspension and 21-inch wheels with carbon-ceramic brakes. 🛠️ 🚢Exclusive Release: Only 15 units will be produced for track enthusiasts, followed by another 54 road-ready models. Pricing details remain under wraps! 💰 #Nilu#Supercar#AlexanderSelipanov#DrivingPassion#V12#Auto

Auto Life

@revheadcrypto · Post #433 · 04.09.2024 г., 16:41

🚗✨ Introducing the new Aston Martin Vanquish with a powerful V12! 🌟 🔧 Equipped with a twin-turbo engine delivering an impressive 835 hp and 1000 Nm of torque (just edging out the Ferrari 12Cilindri at 830 hp)! 💪 ⚡️ Accelerating from 0 to 60 mph (96 km/h) in just 3.2 seconds, this flagship beauty boasts a top speed of 344 km/h! 🏁 🛠️ The Vanquish features a brand new body with a 75% increase in stiffness compared to the DBS. It comes with carbon-ceramic brakes and cutting-edge Bilstein DTX adaptive dampers for an unparalleled driving experience! 🚀 📅 Deliveries of this grand tourer will begin in Q4, with a starting price of $420,000. 💰 #AstonMartin#Vanquish#V12#LuxuryCars#Performance#CarEnthusiasts#Supercar#DrivingExperience#Auto

Auto Life

@revheadcrypto · Post #225 · 02.08.2024 г., 14:13

🚗💨 Exciting news from the German tuning atelier DMC! They've unveiled the first tuning kit for the stunning Lamborghini Revuelto! 🌟 This incredible kit features: ✨ Two different rear wings ✨ An alternative diffuser ✨ Side skirt overlays ✨ New side mirror housings The stock V12 engine delivers a jaw-dropping 1015 horsepower, but with DMC's modifications to the exhaust system and engine control unit, it now boasts an impressive 1099 horsepower! 🔥💪 And here's a twist: all parts from the kit will be available for purchase exclusively in Bitcoin! 💰💻 #Lamborghini#Revuelto#DMC#Tuning#Supercar#V12#Performance#Bitcoin#LuxuryCars#Auto

Auto Life

@revheadcrypto · Post #614 · 29.10.2024 г., 09:28

🚗✨SPOTTED: The Last Longtail Supercar - Pagani Huayra Codalunga!🌟 This stunning masterpiece, crafted in collaboration with the French luxury house Hermès, is one of only five ever made, each priced at a jaw-dropping €7 million! 💰💎 Inspired by the longtail sport prototypes of the 1960s, this special edition features an elongated rear and ditches the rear wing for a sleek design. The Mercedes-AMG V12 has been fine-tuned to deliver an astonishing 840 hp and 1100 Nm of torque! 🔥⚙️ A true work of art on wheels! 🖼️❤️ #Pagani#HuayraCodalunga#LuxuryCars#Supercar#CarSpotting#AutomotiveArt#Hermes#V12#CarEnthusiast#ExoticCars#Auto🚀🌍