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

Резултати

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

Пребарај: #jamesbond

当前筛选 #jamesbond清除筛选
Reuters: World

@reutersworldchannel · Post #149201 · 11.10.2021 г., 06:00

'No Time to Die' debuts below expectations 'No Time to Die,' the latest installment in the James Bond franchise, debuted to $56 million at the North American box office. #News#Reuters#JamesBond#Film Subscribe: http://smarturl.it/reuterssubscribe Reuters brings you the latest business, finance and breaking news video from around the globe. Our reputation for accuracy and impartiality is unparalleled. Get the latest news on: http://reuters.com/ Follow Reuters on Facebook: https://www.facebook.com/Reuters Follow Reuters on Twitter: https://twitter.com/Reuters Follow Reuters on Instagram: https://www.instagram.com/reuters/?hl=en ➖@reutersworldchannel➖

Reuters: World

@reutersworldchannel · Post #149142 · 08.10.2021 г., 22:02

No time for the battery to die: Bond's Aston Martin goes electric Aston Martin - an epitome of British motoring style - is going through a modern twist with the DB5 and DB6 models now being retrofitted to reappear in limited numbers as electric cars. #AstonMartin#JamesBond#News#Reuters#EV#NoTimeToDie Subscribe: http://smarturl.it/reuterssubscribe Reuters brings you the latest business, finance and breaking news video from around the globe. Our reputation for accuracy and impartiality is unparalleled. Get the latest news on: http://reuters.com/ Follow Reuters on Facebook: https://www.facebook.com/Reuters Follow Reuters on Twitter: https://twitter.com/Reuters Follow Reuters on Instagram: https://www.instagram.com/reuters/?hl=en ➖@reutersworldchannel➖

Auto Life

@revheadcrypto · Post #581 · 15.10.2024 г., 13:41

🚗✨ Celebrating 60 Years of Bond with Aston Martin! 🎉 Introducing the stunning Aston Martin DB12 Goldfinger Edition, painted in a striking silver reminiscent of the iconic DB5 from "Goldfinger." 🕶️💎 The Q badge on the bumper adds a touch of intrigue! Inside, luxury reigns with 18-carat gold accents on the central console, and the cherry on top? An embroidered eight of spades on the driver’s sun visor. ♠️✨ Under the hood, it’s all power with a 4.0L twin-turbo V8 engine delivering 680 hp and 800 Nm of torque. 🔥💪 Only 60 exclusive vehicles will be produced, each accompanied by a piece of film history: a 35mm reel from "Goldfinger." 🎬🎞️ #AstonMartin#DB12#GoldfingerEdition#JamesBond#LuxuryCars#60YearsOfBond#Auto

Auto Life

@revheadcrypto · Post #610 · 28.10.2024 г., 06:23

✨ Introducing the Rolls-Royce Phantom Goldfinger! 🚗💨 In celebration of the 60th anniversary of "Goldfinger," this stunning long-wheelbase sedan is a tribute to the iconic film. 🎥💛 Featuring a color scheme reminiscent of the Phantom III Sedanca de Ville driven by the notorious Auric Goldfinger, this masterpiece is truly one-of-a-kind! 🌟 The iconic "Spirit of Ecstasy" is adorned with real gold, and there's even a hidden compartment holding a gold bar shaped like the Phantom! 🪙✨ Get ready to experience luxury like never before! #RollsRoyce#PhantomGoldfinger#JamesBond#LuxuryCars#Goldfinger#AutomotiveArt#Elegance#Auto

Auto Life

@revheadcrypto · Post #418 · 01.09.2024 г., 10:09

🚗✨For Sale: Aston Martin Vanquish!✨🚗 This stunning grand tourer isn't just any car; it was featured in a promotional photoshoot for the James Bond film "Die Another Day" starring Pierce Brosnan! 🌟 🔹Power: 460 HP 🔹Mileage: Over 60,000 km 🔹Price: Up to $100,000 Don't miss your chance to own a piece of cinematic history! 🎬💎 #AstonMartin#Vanquish#JamesBond#DieAnotherDay#LuxuryCars#CarForSale#BondCar#DreamCar#Auto

Мирослава Карпович

@m1r0slavakarpovich · Post #1606 · 23.09.2024 г., 19:00

-Жду Вас вечером.В семь. -А повод? -А повод банален…Обнять…(локации для объятий прилагаются) 😂 24 сентября Алматы 26 сентября Тольятти 27 сентября Ульяновск 28 сентября Москва 29 сентября Краснодар 30 сентября Ростов-на-Дону Жду Вас❤️‍🔥 Девушку Бонда создавали : Папарацци @kamenskaya_art🖤 ШикБлескЛоск @visagiste_olesya💋 #reddress#autumn#september#theatre #2024 #women#femme#photooftheday#photography#friday#moscow#moodoftheday#jamesbond#bondsbaby#lady#mira#fashion#extravaganza#muah#heavenonearth#purelove#astana#actress#model#фото#фотодня#фотосессия#havefun#chique#photobomb