@mygovcoronanewsdesk · Post #11493 · 01.12.2022 г., 07:54
India's G20 Presidency will work towards benefitting humanity as a whole. As the Hon PM Narendra Modi says, "WE CAN!" #G20India
Hashtags
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
Пребарај: #g20india
@mygovcoronanewsdesk · Post #11493 · 01.12.2022 г., 07:54
India's G20 Presidency will work towards benefitting humanity as a whole. As the Hon PM Narendra Modi says, "WE CAN!" #G20India
Hashtags
@MyGovCoronaNewsdesk · Post #12837 · 13.09.2023 г., 08:44
PM Narendra Modi is taking on the role of a Global Unifier. He's uniting nations for the global good, fostering collaboration on a worldwide scale. #G20#G20India
@MyGovHindi · Post #6850 · 13.09.2023 г., 08:45
दुनिया के नेताओं को एक मंच पर लाने एवं एकजुट करने की सराहनीय भूमिका निभा रहे पीएम नरेन्द्र मोदी वह वैश्विक भलाई के लिए देशों को एकजुट कर, विश्वव्यापी स्तर पर सहयोग को बढ़ावा दे रहे है। #G20#G20India
@mygovcoronanewsdesk · Post #11492 · 01.12.2022 г., 06:28
गौरवमयी पल 🇮🇳 आज से भारत प्रतिष्ठित एवं महत्वपूर्ण #G20 समूह की अध्यक्षता आधिकारिक तौर पर ग्रहण करेगा। आइए 'वसुधैव कुटुम्बकम' के मंत्र के साथ पूरी दुनिया को एक साथ लेकर आगे बढ़ने का संकल्प लें। #G20India https://youtu.be/VuQLi0_34vw
@mygovcoronanewsdesk · Post #11990 · 08.02.2023 г., 15:46
Come, Explore India's Digital Transformation Journey alongside the 1st DEWG Meeting and experience the Progress of Technology & latest innovations. 📍Lucknow 🗓13-15 Feb 🕑 2 PM onwards #G20DEWG#G20India
@mygovcoronanewsdesk · Post #11814 · 19.01.2023 г., 11:22
📣 Announcing! 1st Digital Economy Working Group Meeting taking place in Lucknow from February 13-15, 2023. #G20IndiaDEWG#G20India
Hashtags
@mygovcoronanewsdesk · Post #11494 · 01.12.2022 г., 10:34
India: the mother of democracy moving forward with a united voice and #JanBhagidari #G20India#NewIndia
Hashtags
@mygovcoronanewsdesk · Post #12033 · 12.02.2023 г., 11:57
"G20-DIA bringing Hon'ble PM Narendra Modi's dream to life" Be part of G20 #DigitalInnovationAlliance. Know more & Apply at: meitystartuphub.in/g20-dia/ #G20India#G20DEWG
@mygovcoronanewsdesk · Post #12321 · 13.03.2023 г., 05:19
Are you interested in creating digital innovations for the upliftment of societies? Participate in G20 #DigitalInnovationAlliance Visit: https://mygov.in/task/launch-applications-g20-digital-innovation-alliance/ #G20DIA#G20India
@mygovcoronanewsdesk · Post #11970 · 06.02.2023 г., 08:06
Calling startups in the field of #agritech & other sectors, developing digital solutions that can reduce the digital divide and boost the global economy for G20 #DigitalInnovationAlliance. Know more at https://mygov.in/task/launch-applications-g20-digital-innovation-alliance/ #G20India
@mygovcoronanewsdesk · Post #11991 · 09.02.2023 г., 06:26
The Digital Experience Centre & Digital India Exhibition scheduled alongside the 1st Meeting of #G20DEWG in Lucknow will be a learning opportunity for all #DigitalNagriks. See you there! #G20India
Hashtags