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

Резултати

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

Пребарај: #opentelemetry

当前筛选 #opentelemetry清除筛选
GitHub Trends

@githubtrending · Post #15055 · 13.08.2025 г., 12:00

#go#open_telemetry#opentelemetry The OpenTelemetry Collector Contrib is a collection of extra components that extend the core OpenTelemetry Collector, helping you collect, process, and export telemetry data like traces, metrics, and logs from your applications. It supports many features such as filtering sensitive data, batching, retries, and custom processing, which improve security, reliability, and performance of your observability pipeline. You can build custom distributions using these components to fit your needs. This helps you monitor complex systems more easily, reduce costs, and maintain flexibility by supporting many data formats and backends without changing your application code. It is maintained by a community of experts ensuring quality and support. https://github.com/open-telemetry/opentelemetry-collector-contrib

GitHub Trends

@githubtrending · Post #14948 · 11.07.2025 г., 12:30

#go#logging#metrics#opentelemetry#tracing OpenTelemetry-Go is a tool for Go applications that helps you track how your software performs by collecting data like traces and metrics, then sending this information to monitoring platforms so you can see what’s happening inside your app in real time[2][3][4]. It works on many operating systems and Go versions, and you can use it by adding a few lines of code to your app and setting up an exporter. This makes it much easier to find and fix problems, understand how your app is running, and keep everything reliable and fast[2][3][4]. https://github.com/open-telemetry/opentelemetry-go

GitHub Trends

@githubtrending · Post #14859 · 24.06.2025 г., 11:30

#typescript#cli#clustering#concurrency#dependency_injection#effect#error_handling#javascript#observability#opentelemetry#platform#schema#typescript#workflows Effect is a powerful TypeScript framework that helps you build reliable and complex applications by managing side effects like logging, network calls, and database operations in a safe and organized way. It uses a core `Effect` type to describe workflows that are lazy, composable, and type-safe, allowing you to handle errors and dependencies explicitly. The framework is modular, with many packages for AI, CLI tools, distributed computing, SQL databases, and more, making it flexible for various needs. Using Effect improves code quality, concurrency handling, and maintainability, helping you write robust TypeScript apps efficiently[1][2][4][5]. https://github.com/Effect-TS/effect

GitHub Trends

@githubtrending · Post #14691 · 10.05.2025 г., 00:00

#csharp#architecture#aspnetcore#clean_architecture#cqrs#ddd#dotnet#dotnetcore#event_driven_architecture#event_sourcing#kubernetes#masstransit#messaging#microservice#microservices#oauth2#opentelemetry#software_architecture#software_design#software_engineering#vertical_slice_architecture Migrating from a monolithic architecture to a cloud-native microservices architecture offers several benefits. It improves scalability, allowing different parts of the application to grow independently. This approach also enhances reliability by isolating faults, so if one service fails, others continue to work. Additionally, microservices enable faster deployment and updates, as each service can be developed and deployed separately. This flexibility allows teams to use the best technology for each service, making development more efficient and agile[2][3][5]. https://github.com/meysamhadeli/monolith-to-cloud-architecture