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

Резултати

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

Пребарај: #2026amnestylaw

当前筛选 #2026amnestylaw清除筛选
Venezuelanalysis

@venanalysis · Post #2282 · 23.02.2026 г., 14:10

📰 NEWS | Venezuelan Parliament Approves Amnesty Law, Rodríguez Calls for ‘Peace and Tolerance’ Venezuela’s National Assembly has passed the Amnesty Law for Democratic Coexistence, establishing a blanket amnesty for crimes committed in the context of political violence between 1999 and 2026. The legislation references events including the 2002 coup attempt, the 2014 and 2017 protests, and unrest following the July 2024 presidential elections. Article 7 excludes serious human rights violations, crimes against humanity, war crimes, homicide, corruption offenses in public office, and drug trafficking with sentences exceeding nine years. Parliament created a Special Monitoring Commission to oversee implementation. According to its president, 379 amnesty requests have been processed, with further cases under revision. Read our full report here 👉🏾https://venezuelanalysis.com/news/venezuelan-parliament-approves-amnesty-law-rodriguez-calls-for-peace-and-tolerance/ #2026AmnestyLaw#Opposition

Venezuelanalysis

@venanalysis · Post #2273 · 10.02.2026 г., 14:08

📰 NEWS | Venezuelan Authorities Begin Consultations on Amnesty Law The Venezuelan National Assembly has begun nationwide consultations on a preliminarily approved “Amnesty Bill for Democratic Coexistence,” holding meetings with community peace judges, civil society organizations and university law faculties. Lawmakers said the process aims to gather input before a revised version is submitted for a final vote in the coming weeks. The bill seeks to pardon political and related crimes committed between January 1, 1999, and January 30, 2026, while explicitly excluding serious human rights violations, crimes against humanity, homicide, drug trafficking and corruption. Former Spanish President José Luis Rodríguez Zapatero endorsed the initiative during a meeting in Caracas, describing it as a turning point for national reconciliation. Read the full report here 👉https://venezuelanalysis.com/news/venezuelan-authorities-begin-consultations-on-amnesty-law/ #2026AmnestyLaw#Opposition

Venezuelanalysis

@venanalysis · Post #2286 · 28.02.2026 г., 00:00

📰 NEWS | Venezuela: Attorney General and Ombudsman Resign as Authorities Process Thousands of Amnesty Requests National Assembly President Jorge Rodríguez confirmed the resignations of Attorney General Tarek William Saab and Ombudsman Alfredo Ruiz. Parliament declared urgency, formed a 13-member committee to appoint new officials within 30 days, and named interim replacements. The developments come as authorities process Amnesty Law requests covering cases dating back to 1999. Deputy Jorge Arreaza reported 8,110 petitions filed since approval last week, with 4,757 individuals benefiting so far, including 223 released from prison and 4,534 cleared of parole-type measures. Read our full report here: https://venezuelanalysis.com/news/venezuela-attorney-general-and-ombudsman-resign-as-authorities-process-thousands-of-amnesty-requests/ #2026AmnestyLaw#NationalAssembly#TarekWilliamSaab