Скорее всего уже слышали, что складывать строки через + это плохая практика. Падение производительности, и всё такое. Без лишних слов, давайте измерять:
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
📝 INTERVIEW | Pending Tasks for Chavista Feminism: A Conversation with Roraima Rivas-Liendo
In the latest VA interview, Roraima Rivas-Liendo, activist and spokesperson for the Venezuelan feminist collective FaldasR, discusses legislative advances, ongoing challenges, and the state of sexual and reproductive rights in Venezuela.
For over a decade, FaldasR has provided information and support to women and people capable of gestation across the country. The organization’s latest report highlights two trends: a rise in unsafe abortion attempts and increased early engagement from those seeking guidance. Rivas-Liendo notes that many now recognize abortion as a collective right, signaling a shift toward self-determination despite legal restrictions.
🔗 Read the full interview here: shorturl.at/YjpgI
#Feminism#Sanctions
📸 IN IMAGES | Venezuela: 1,600 Women Discuss ‘Communal Feminism’ at First National Gathering
On March 29, more than 1,600 women took part in the Communard Union’s first national gathering on communal feminism in Caracas. The meeting set four key priorities: developing a feminist economy, strengthening healthcare, eliminating gender-based violence, and expanding political participation. A commission was appointed to oversee these initiatives, with annual follow-up meetings planned.
🔗 Don’t miss the full gallery here 👉🏼https://venezuelanalysis.com/images/venezuela-1600-women-discuss-communal-feminism-at-first-national-gathering/
#CommunardUnion#Communes#Feminism
🎙PODCAST | The Venezuelanalysis Podcast Episode 35: Popular Feminism in Venezuela
Our latest podcast episode coincides with International Working Women’s Day (March 8) to take stock of popular feminist struggles under the Bolivarian Revolution in Venezuela.
VA staff member Cira Pascual Marquina joins host José Luis Granados Ceja to discuss the impact of sanctions on women, the role of women in popular power, a recent conservative/religious offensive, and lots more!
Watch the full episode here: https://www.youtube.com/watch?v=ZO_aA0Zf2t8&t=2607s
#Feminism#GrassrootsMovements
📝 INTERVIEW | Feminism and Revolution: A Conversation with Alejandra Laprea
In the latest VA interview, Alejandra Laprea, a popular feminist and member of the World March of Women, discusses how popular feminism in Venezuela continues to shape the revolution from the ground up. She stresses the importance of unity within the feminist movement, advocating for a collective, consensus-based agenda.
"We are experiencing a moment of setbacks at the global, continental, and national levels. In Venezuela, the feminist movement must come together and build a common agenda – one that is truly collective and based on consensus, rather than a mere compilation of different perspectives." States Alejandra.
🔗 Read the full interview here: https://shorturl.at/ppCss
#Feminism#Sanctions#WomensRights
Explore the intricacies of Venezuela's battle against women's oppression as feminist anthropologist Aimee Zambrano Ortiz delves into the subject in this interview.
Highlighting legislative strides and the significance of initiatives like the Femicide Monitor, Zambrano Ortiz underscores the ongoing struggle for gender equality within the Bolivarian Process.
Click here to read the full interview 👉🏼https://bit.ly/43yXiHn
#feminism#sanctions#women
Our latest podcast episode coincides with International Working Women's Day (March 8) to take stock of popular feminist struggles under the Bolivarian Revolution in Venezuela.
VA staff member Cira Pascual Marquina joins host José Luis Granados Ceja to discuss the impact of sanctions on women, the role of women in popular power, a recent conservative/religious offensive, and lots more!
Follow the link to subscribe and watch/listen: https://www.patreon.com/posts/123944102
#InternationalWomensDay#Feminism#Venezuela#Podcast
Imagine how this almost obsolete tradition would be tainted today with #trannies, #immigrants, #LGBT, #feminism and all that is anti-British.
https://youtu.be/zLzc9JaJ-PY
🗓️ MILESTONE | International Working Women’s Day
✊🏽💜 Across the globe, this day serves as a vital reminder of the ongoing struggles for equality, justice, and the dismantling of oppressive systems. Solidarity extends to every corner of the earth, where working-class women continue to fight for their rights, equality, and recognition.
🔗 Click here to discover the revolutionary Venezuelan women who played a pivotal role in shaping history through their courage and commitment: https://www.instagram.com/p/DG8K7vStGHM/?igsh=MTkydWM1cGF1YXRqcA==
#IWD#feminism#InternationalWorkingWomensDay
📝 INTERVIEW | Women’s Emancipation through Economic Transformation: A Conversation with Sandra Angeleri
Historian Sandra Angeleri speaks about the legacy of Nora Castañeda, a feminist economist who led one of the Bolivarian Revolution’s most innovative institutions, in her newly published book.
From her early political formation in the barrios of Caracas to her leadership of Banmujer (the Women’s Development Bank), Castañeda pushed for structural change, fighting to include unpaid domestic work in Venezuela’s Constitution and helping to build institutional models that challenged both patriarchy and capitalism.
Her work laid the foundation for economic autonomy among working-class women. 'Banmujer wasn’t just about lending money, it was about collective empowerment,' Angeleri notes.
👉 Follow the link to read the interview: https://shorturl.at/ubpwR
#Banks#Feminism#WomensDevelopmentBank
While often considered a gatekeeper, Murray is correct here, stating how it's always useful idiots backing #Marxist groups such as #LGBT, #BLM, #feminism etc and claiming to represent their non-existent communities.
https://youtu.be/ntX0xWvjGrI