Скорее всего уже слышали, что складывать строки через + это плохая практика. Падение производительности, и всё такое. Без лишних слов, давайте измерять:
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
🎓ETHIOPIAN STUDENTS IN RUSSIA: A CROSS-CONTINENTAL EDUCATIONAL JOURNEY
ኢትዮጵያውያን ተማሪዎች በሩሲያ፡ የትምህርት ጉዞ
💡Why thousands choose Russian universities:
Quality education in medicine, engineering, and economics that builds Ethiopia's future workforce.
🏛️TOP UNIVERSITIES | ዋና ዩኒቨርሲቲዎች:
• Moscow State University (МГУ) - Medicine: 350,000-450,000 RUB/year
• RUDN University - International programs: 280,000-380,000 RUB
• Saint Petersburg State - Engineering: 320,000-420,000 RUB
• Kazan Federal University - Economics: 250,000-350,000 RUB
❄️WINTER SURVIVAL GUIDE | የክረምት መጸብ:
🧥 "Первые три месяца я носил 5 курток одновременно!" - Ahmed, 2nd year
🌡️ From +40°C Ethiopia → -35°C Russia shock
🏠 "Общага спасла мне жизнь" - centralized heating discovery
🍲CULINARY ADVENTURES | የምግብ ጉዞ:
😋 "Что это за красный суп? Похож на Ethiopian stew!" - First borscht experience
🥞 Injera + Russian blini = unexpected combination success
☕ "Где настоящий Ethiopian coffee?!" - desperate search stories
💰FINANCIAL REALITY | የገንዘብ እውነታ:
• Monthly living costs: 15,000-25,000 RUB (~4,000-7,000 ETB)
• "Стипендия 2,000 рублей хватает на хлеб и чай" - budget student life
• Part-time work opportunities in translation/tutoring
🎯PRO TIPS | ጠቃሚ ምክሮች:
📚 Russian language prep is CRUCIAL - start 6 months early
🏥 Medical insurance mandatory: ~12,000 RUB/year
📱 Download "Тройка" app for Moscow transport
🏠 "Ищите общагу рядом с метро" - location matters!
✨SUCCESS STORIES:
"После 6 лет в России, теперь работаю врачом в Addis Ababa. Спасибо, Россия!" - Dr. Meron, graduate
Expert-reviewed content | Verified by Ethiopian student community in Russia
#EthiopianStudents#RussianEducation#StudyAbroad#ኢትዮጵያ#EducationJourney🇪🇹🇷🇺
🎓 ETHIOPIAN EDUCATION: Universities, Careers & Global Dreams
ትምህርቶች በኢትዮጵያ
💡 Discover Ethiopia's education landscape: from ancient learning centers to modern universities, where young Ethiopians dream of studying abroad.
🏛️ TOP UNIVERSITIES IN ETHIOPIA | ታዋቂ ዩኒቨርሲቲዎች በኢትዮጵያ
• Addis Ababa University (1950) - The flagship, medicine & engineering excellence
• Jimma University - Medical powerhouse, largest health sciences faculty
• Mekelle University - Engineering & technology focus, northern Ethiopia
• Bahir Dar University - Agriculture & water resources specialization
• Hawassa University - Business & agricultural sciences hub near beautiful Lake Hawassa
📍 HAWASSA UNIVERSITY SPOTLIGHT | ሀዋሳ ዩኒቨርሲቲ
• Located in stunning Hawassa city with lakeside campus views
• Strong business school - produces entrepreneurs for Ethiopia's growing economy
• Agricultural innovation hub with international research partnerships
• Why business matters: Ethiopia needs skilled managers and finance experts for economic transformation from agriculture to industrialization
🔥 MOST DEMANDED PROFESSIONS | ኢትዮጵያ ውስጥ የሚፈለጉ ሙያዎች
• Medicine & Health Sciences - doctor shortage in rural areas (critical need!)
• Engineering (Civil, Electrical, Software) - infrastructure boom demands
• Agriculture & Food Science - 80% population depends on farming
• IT & Computer Science - digital transformation wave
• Business & Economics - growing private sector opportunities
🔬 WHAT IS STEM? | ሳይንስ፣ ቴክኖሎጂ፣ ኢንጂነሪንግ እና ሒሳብ
• Science, Technology, Engineering, Mathematics - the future job engines
• Government priority: 70% STEM vs 30% humanities in universities
• Critical for Ethiopia's Vision 2030 development goals
• Creates jobs in manufacturing, tech, healthcare, and infrastructure sectors
🌍 ETHIOPIANS ABROAD | የውጭ ሀገር የትምህርት እድል
• Top destinations: USA, Germany, UK, Russia, China, India
• Popular fields: Medicine (Russia/Ukraine), Engineering (Germany), IT (USA)
• Scholarship programs: Fulbright, DAAD, Chinese Government, Indian ICCR
• Brain drain vs. knowledge transfer - complex challenge
💰 EDUCATION COSTS & ACCESS | የ ትምህርት ወጪና ተደራሽነት
• Public universities: ~5,000-8,000 ETB/year (affordable!)
• Private institutions: 70,000-150,000 ETB/year
• English medium instruction from Grade 9+
• Rural-urban education gap - major inequality issue
🚀 FUTURE TRENDS | የወደፊት አዝማሚያዎች
• STEM focus - government priority for development
• Online learning expansion post-COVID
• Technical & Vocational Education (TVET) growth
• International partnerships increasing
💰 PRO TIPS:
Ethiopian Students Union associations exist in major global cities. Many Ethiopian graduates abroad send remittances home - $5+ billion annually. The government offers incentives for diaspora professionals to return and contribute to development. Entrepreneurship education is crucial for addressing youth unemployment.
✨ Expert-reviewed content | Verified by local Ethiopian education specialist
#Ethiopia#ኢትዮጵያ#EthiopianEducation#StudyAbroad#HigherEducation#EthiopianStudents