Скорее всего уже слышали, что складывать строки через + это плохая практика. Падение производительности, и всё такое. Без лишних слов, давайте измерять:
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
#csharp
The Model Context Protocol (MCP) is an open standard that lets AI models connect easily and securely to external data sources and tools, like business systems or cloud services. It acts like a universal adapter, enabling AI to access the right context and data to perform tasks accurately and efficiently. Microsoft offers many MCP servers that link AI with services such as Azure DevOps, SQL databases, Microsoft 365, and more, allowing AI to interact naturally with your data and workflows. This helps you get smarter AI assistance, better automation, and easier integration across your tools.
https://github.com/microsoft/mcp
#csharp
RunCat 365 is a fun and cute app that shows a running cat animation on your Windows taskbar. The cat’s running speed changes based on your computer’s CPU usage, so you can easily see how hard your computer is working just by watching the cat. It’s made for Windows only and is built with C# and .NET 9.0. This app adds a playful and useful visual indicator to your taskbar, making it easier and more enjoyable to monitor your PC’s performance at a glance. It’s free and open-source, with many users enjoying its charm and functionality[4].
https://github.com/Kyome22/RunCat365
#csharp
The eShop reference application is a sample e-commerce website built using .NET 9 and a services-based architecture. It helps developers learn how to create modern web applications. To use it, you need to install .NET 9 SDK, Docker, and possibly Visual Studio or Visual Studio Code. This application is beneficial because it provides a real-world example of how to structure and deploy a complex web application, making it easier for developers to understand and implement similar projects.
https://github.com/dotnet/eShop
#csharp
JSC “KDB Bank Uzbekistan” is looking for Middle or High level of S/W designer with C#, C Programming
Job description:
Software design
· Experience to design new software for multi users using middleware like Apache Kafka
External Interface module development, maintenance and support
· Receiving and analyzing user’s request
· Coding and Test
· Implementation and documentation
· Supporting of the banking system users
Professional requirements:
· Experience of development tool: Visual Studio, GCC or any C compiler
· Experience of Database environment (Oracle)
· At least 2-3 years of experience in the field of programming in C/C++ & C#
· Time management (in order to meet deadlines set by the management)
· English Speaking (should be able to execute instruction and verbal report by English)
· Good written and spoken Russian
Working conditions:
Salary based on interview results, depends on skills and knowledge from 12 mln.soums to 22 mln. soums
Working hours 5/2 from 9:00 - 18:00
Office is located in the center of Tashkent
Benefits:
Medical insurance
Incentive payments for Holidays
Performance bonus
Material assistances for special events (marriage, birth of child and etc.)
Mortgage loan, overdraft facility
Teambuilding
Contacts:
Nozima Yakubova, Head of HR dpt.
telegram: @nozimayakubova
email: [email protected]
More information you can get from our web site: https://kdb.uz/en
#vakansiya#dotnet#csharp
Davr Bank Middle/Senior .NET dasturchi izlamoqda
Talablar:
• C# / .NET Framework
• ASP.NET, REST API
• WCF, Windows services
• Oracle
• JSON/XML
Qo'shimcha ma'lumotlar:
• Maosh - 500$ dan 2000$ gacha
• Ish vaqti - 9:00 dan 18:00 gacha
• Hudud - Toshkent shaxri
Resume yuboring:Nodir
.NET Uzbekistan Community
______
Telegram | Instagram | Youtube
✅ Завтра
Шахматный клиент-сервер на C#. Часть 2. Шахматная доска + фигуры. Unity3D.
📅 28 февраля / 19:00 (время МСК) / онлайн
💵 Бесплатно
📝 Регистрация тут: https://goo.gl/P8dT1K
План вебинара:
~ Вступление. Установка Unity3D.
~ Размещение доски с фигурами.
~ Перемещение мышкой.
~ Фиксация хода.
~ Взятие фигур.
~ Проверка правил.
Для участия в вебинаре обязательна регистрация. На емейл, который вы укажете в регистрационной форме, 28 февраля 2018 года будет отправлено письмо-приглашение со ссылкой на трансляцию.
#Unity3D#Csharp#online#онлайн