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

Резултати

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

Пребарај: #healthsecurity

当前筛选 #healthsecurity清除筛选

Last Friday, the National One Health Technical Committee (NOHTC) brought together key stakeholders across human, animal, and environmental health to: ✅ Review progress on previous action points ✅ Share updates on ongoing programmes and current outbreaks ✅ Align strategies to strengthen Nigeria’s health security through coordinated, multisectoral action Together, we’re advancing a resilient, data-driven OneHealth system for prevention, preparedness, and response. #HealthSecurity#NCDCNigeria#PublicHealth#OneHealth

🚨 Public Health Advisory: Ebola Virus Disease (EVD) The Nigeria Centre for Disease Control and Prevention (NCDC) has released a public health Advisory following the announcement of an Ebola Outbreak in DR Congo. Though no case has been reported in Nigeria, NCDC is closely monitoring the situation. Key Preventive Measures: ▪️Wash hands frequently with soap & running water ▪️Avoid contact with sick individuals showing symptoms like fever, vomiting, diarrhoea & bleeding ▪️Avoid bushmeat and ensure all animal products are well-cooked ▪️Healthcare workers: maintain high IPC standards & use PPE 🧑‍⚕️ Read the full advisory 🔗https://ncdc.gov.ng/themes/common/docs/protocols/369_1757166366.pdf If you or anyone you know (with recent travel to affected areas) experiences symptoms, call 📞 6232 or your State Ministry of Health hotline immediately. Together, we can prevent the spread and protect Nigeria. 🇳🇬 #EbolaAdvisory#HealthSecurity#NCDCNigeria

🚨 PUBLIC HEALTH ADVISORY 🚨 The Nigeria Centre for Disease Control and Prevention (NCDC) has announced that Nigeria currently has no confirmed case of Ebola Virus Disease (EVD), following the ongoing outbreak in the Democratic Republic of the Congo and a reported imported case in Uganda. 🦠 Ebola Virus Disease is a severe viral illness transmitted through direct contact with infected bodily fluids or contaminated materials. Common symptoms include: ✅Fever ✅Headache ✅Weakness ✅Muscle pain ✅Vomiting ✅Diarrhoea ✅severe cases, unexplained bleeding. The NCDC is actively strengthening surveillance, laboratory readiness, infection prevention, and public awareness efforts across the country. Nigerians are advised to remain calm, maintain good hand hygiene, avoid misinformation, and report unusual illnesses promptly. Stay informed through official public health channels only. Together, we can strengthen preparedness and protect public health. #Ebola#PublicHealth#NCDCNigeria#HealthSecurity

#Ebola is caused by the Ebolavirus — a group of viruses with several species, including Zaire, Sudan, Bundibugyo, Taï Forest, and Reston ebolavirus (which affects animals but not humans). Knowing the cause helps us strengthen prevention and response efforts. 💪🏾 Stay Safe, Stay Protected! #EbolaAwareness#HealthSecurity#NCDCNigeria

Our first strategy 'Idea to Reality' incorporated a new vision and mission that cascaded into 5 Strategic Goals, 22 Objectives and 89 Activities. TOMORROW, November 21, marks another major milestone for #healthsecurity champions as we launch the: 📣Nigeria Centre for Disease Control and Prevention Strategy (2023-2027): #VisiontoAction📣 Don't miss out. Join us online via bit.ly/NCDCStrategyLaunch #IAmHealthSecurity