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 слични објави

Пребарај: #know

当前筛选 #know清除筛选
Business Lessons™

@business_idea4 · Post #4733 · 27.01.2026 г., 17:26

Here are 5 key takeaways from the book "STRATEGIZE TO WIN" - 1. #Know your strengths and weaknesses. This is the foundation of any successful strategy. Once you know what you're good at and what you're not so good at, you can start to build a strategy that plays to your strengths and minimizes your weaknesses. 2. #Set clear goals. What do you want to achieve? What are your long-term and short-term goals? Once you know what you want to achieve, you can start to develop a strategy to get there. 3. #Understand your competition. Who are your competitors? What are their strengths and weaknesses? What are their goals? Once you understand your competition, you can start to develop a strategy that will give you an edge. 4. #Be flexible. The world is constantly changing, so your strategy needs to be flexible enough to adapt to change. Be prepared to adjust your strategy as needed. 5. #Execute your strategy. This is the most important step of all. Once you have a strategy, you need to execute it. This means taking action and making sure that your strategy is working. Here are some additional key takeaways from the book: A. #Strategy is not a one-time event. It is an ongoing process that needs to be reviewed and updated regularly. B. #Strategy is not about perfection. It is about progress. You will never have a perfect strategy, but you can always improve your strategy by learning from your mistakes and by making adjustments as needed. C. #Strategy is about execution. It is not enough to have a good strategy. You also need to be able to execute your strategy effectively. I hope these key takeaways help you on your journey to strategizing to win. 💠Join 🔺 Share @Business_Idea4💠

MONEY SECRETS

@businessideas101 · Post #1247 · 14.06.2025 г., 06:23

Here are 5 key takeaways from the book "STRATEGIZE TO WIN" - 1. #Know your strengths and weaknesses. This is the foundation of any successful strategy. Once you know what you're good at and what you're not so good at, you can start to build a strategy that plays to your strengths and minimizes your weaknesses. 2. #Set clear goals. What do you want to achieve? What are your long-term and short-term goals? Once you know what you want to achieve, you can start to develop a strategy to get there. 3. #Understand your competition. Who are your competitors? What are their strengths and weaknesses? What are their goals? Once you understand your competition, you can start to develop a strategy that will give you an edge. 4. #Be flexible. The world is constantly changing, so your strategy needs to be flexible enough to adapt to change. Be prepared to adjust your strategy as needed. 5. #Execute your strategy. This is the most important step of all. Once you have a strategy, you need to execute it. This means taking action and making sure that your strategy is working. Here are some additional key takeaways from the book: A. #Strategy is not a one-time event. It is an ongoing process that needs to be reviewed and updated regularly. B. #Strategy is not about perfection. It is about progress. You will never have a perfect strategy, but you can always improve your strategy by learning from your mistakes and by making adjustments as needed. C. #Strategy is about execution. It is not enough to have a good strategy. You also need to be able to execute your strategy effectively. I hope these key takeaways help you on your journey to strategizing to win. Thank you for reading 📖

搜书神器 读书动态

@BookLogSFW · Post #91115 · 18.05.2026 г., 06:03

书名:crash course for the new gre 4th editio - princeton review 文件:英文 · MOBI · 2MB · 4万字 · 0R 统计:308热度 | 5下载 | 1点赞 | 0收藏 评级:0分 (0人) 💬 质量:5分 (0人) 标签:#answer#question#Quantity#one#choices#two#number#choice#get#passage#re#time#word#like#questions#sentence#know#problem#GRE#first#find 上传:👤Swof #预览#SFW#收藏书籍 📜我喜欢的书籍[1本]