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

Резултати

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

Пребарај: #driverless

当前筛选 #driverless清除筛选
Car News

@car_news · Post #630 · 12.10.2024 г., 12:31

🚘 Cybercab announced: Elon Musk’s robotaxi is finally here 📍 Tesla boss Elon Musk has unveiled the firm's long-awaited robotaxi, the Cybercab, at the Warner Bros Studios in Burbank, California. 🚕 The robotaxi is a purpose-built autonomous vehicle, lacking a steering wheel or pedals, meaning it will need approval from regulators before going into production. The design was futuristic, with doors that open upward like butterfly wings and a small cabin with only enough space for two passengers. There was no steering wheel or pedals, nor was there a plug — Musk said the vehicle charges inductively to regain power wirelessly. 🚐 In a surprise, the company also revealed a "robovan," a self-driving van capable of carrying up to 20 passengers or being configured for cargo purposes. 🪙 Musk said that autonomous cars are expected to be 10–20 times safer than human-driven vehicles and could cost as little as 20 cents per mile, compared to the $1 per mile for city buses. @CarsNews #Tesla#driverless

Car News

@car_news · Post #105 · 07.06.2024 г., 09:09

New 🚘 electric cars will get Chinese autopilot It will be developed by startup Momenta and will debut on the CLA electric sedan. The hardware will be based on Nvidia's Orin X chip. The all-electric CLA will be equipped with a high-level intelligent driving system that does not rely on high-definition maps. This advanced system will provide navigation in the city, and mass production of the electric car is scheduled for April 2025. Mercedes-Benz is one of Momenta's investors, along with GM and SAIC. @CarsNews #Mercedes#EV#driverless

Car News

@car_news · Post #1763 · 26.12.2025 г., 10:45

🚕Waymo robotaxis are back at the center of a scandal 📍 This time, the vehicles caused chaos on the streets of San Francisco. 🚥 The autonomous taxis use the traffic-light system for navigation, so when it goes down, route planning breaks as well. ⛔ For several hours, Waymo cars stood on the roads like bricks, blocking other drivers from getting through. Is rise of the the machines beginning? #driverless#incidents@Car_News

Car News

@car_news · Post #1741 · 12.12.2025 г., 13:33

😰Three Waymo robotaxis caused a “standoff” and blocked a street in San Francisco 📰 In the northern part of San Francisco, three Waymo autonomous taxis got stuck on a narrow street, completely blocking traffic. Two cars lightly collided while trying to maneuver, after which both went into emergency mode, and the third stopped right in front of them, creating a full traffic jam. 😤 Because of this, residents couldn’t leave their driveways and had to wait for company engineers to intervene and resolve the situation. All vehicles were empty — no passengers were inside. 💬 Waymo commented on the incident, calling it a “learning moment” for improving their autonomous driving system. #driverless#incidents@Car_News