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

Пребарај: #manhart

当前筛选 #manhart清除筛选
Auto Life

@revheadcrypto · Post #182 · 27.07.2024 г., 16:43

🚀 Unleashing the Beast! The Mercedes-AMG GLE, enhanced by Manhart, now boasts a staggering 800 horsepower and a Russian body kit. 💥 🔥 Originally, the V8 "mild-hybrid" engine produced 612 hp and 850 Nm. Manhart's custom supercharger unit and control module upgrade pushed the power output to a whopping 800 hp and 1000 Nm. 🖤 A sleek carbon body kit from the Russian tuning firm, TopCar Design, was added to complete the look. #MercedesAMG#Manhart#TopCarDesign#TunedCars#Auto🏁

Auto Life

@revheadcrypto · Post #405 · 29.08.2024 г., 16:12

🚗💨Manhart Unleashes 200+ Extra Horses on the Toyota Supra!🏎️✨ The stock 3.0L inline-six engine of the Toyota Supra packs a punch with 340 hp. But the tuning experts at Manhart have taken it to the next level, boosting it to an impressive 550 hp and a whopping 770 Nm of torque! ⚡️🔧 But that’s not all! The stunning coupe also features: - Eye-catching aerodynamic body kit 🛠️ - Re-tuned suspension for enhanced performance 🏁 - New wheels for that perfect look! 🖤 🛒 Individual parts available: - Engine upgrade: €11,999 - New exhaust system: €5,050 - Body kit: €13,500 - Wheels: €3,070 per set - Coilovers: €3,100 per set #Manhart#ToyotaSupra#Tuning#CarEnthusiast#PerformanceUpgrade#CarLovers#Auto

Auto Life

@revheadcrypto · Post #601 · 23.10.2024 г., 06:50

🚗💨Exciting News for BMW M5 Fans!💨🚗 German tuning house Manhart is set to unleash a beastly 800 horsepower from the latest BMW M5! 🔥 With their proven track record of boosting the XM crossover to an astonishing 900 hp, we can’t wait to see what they have in store for the M5! But that's not all! The M5 and its Touring variant will also receive: • A more aggressive body kit 🛠️ • A revamped suspension with lowered ride height 🚧 • Stunning new wheels! 🏎️✨ #BMWM5#Manhart#Tuning#Performance#800HP#CarEnthusiasts#LuxuryCars#Auto

Auto Life

@revheadcrypto · Post #551 · 07.10.2024 г., 07:18

🚗💥 Introducing the Manhart MHXM 900! 💥🚗 Get ready to experience the ultimate BMW XM upgrade! 🌟 🔧Power Boost: From a stock 748 hp and 1000 Nm to an astonishing 900 hp and 1200 Nm! 💪🔥 ⚙️Suspension Upgrade: Featuring H&R springs for enhanced handling! 🛠️ 🛞Stunning Wheels: Equipped with eye-catching 24-inch Manhart wheels! 😍 🌌Carbon Fiber Body Kit: Lightweight and aggressive styling that enhances performance! 🖤 🖌️Luxurious Interior: Finished in a sleek grey-orange scheme with leather, Alcantara, and carbon accents! ✨ #Manhart#MHXM900#BMW#Performance#Tuning#CarEnthusiast#LuxuryCars#CarbonFiber#Auto

Auto Life

@revheadcrypto · Post #654 · 28.11.2024 г., 11:22

🚗💨Manhart’s BMW M3: A Powerhouse!💥 The tuning experts at Manhart have taken the iconic BMW M3 to a whole new level, surpassing the power of the new BMW M5! 🔥 🔧Engine Upgrade: Boosted by a staggering 345 hp, the total output now stands at an incredible 855 hp and 1090 Nm of torque! 💪⚙️ 📈Transmission: Enhanced 8-speed automatic for smooth power delivery! ✨Other Upgrades: • Signature carbon fiber body kit for that aggressive look 🏎️ • Adjustable dampers for a tailored ride experience 🛠️ • Carbon strut brace for increased rigidity 🔩 This specific MH3 800 Touring has already clocked 12,500 km and is up for grabs at €212,000! 💰 #Manhart#BMWM3#PowerUpgrade#CarEnthusiast#LuxuryCars#Tuning#Performance#MH3800Touring#Auto