@animal_fighting · Post #262 · 22.09.2022 г., 10:05
Man VS Sheep A dangerous game😀 #sheep
Hashtags
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
Пребарај: #sheep
@animal_fighting · Post #262 · 22.09.2022 г., 10:05
Man VS Sheep A dangerous game😀 #sheep
Hashtags
@animal_fighting · Post #238 · 09.09.2022 г., 11:03
Aggressive sheep is in the town #sheep🐑
Hashtags
@animal_fighting · Post #130 · 04.07.2022 г., 12:46
Sheep VS Man Just tried to protect a cub #sheep
Hashtags
@SukoFaultyArtLair · Post #4567 · 15.12.2019 г., 01:58
https://twitter.com/NarukaLewd #male#sheep
@StickersChannel · Post #1086 · 04.04.2016 г., 11:45
❎ Baach ↘️https://telegram.me/addstickers/Baach #Sheep#Animals
@animal_fighting · Post #172 · 23.07.2022 г., 11:03
Sheep VS Camel An insolent was punished #sheep🐑#camel🐪
@animal_fighting · Post #98 · 14.06.2022 г., 10:04
Horse VS Sheep It's better not to deal with a crazy sheep 😁 #horse#sheep
@animal_fighting · Post #126 · 01.07.2022 г., 11:03
Sheep VS Zebu An attack failed😀 #sheep#zebu
@TgSticker · Post #42951 · 23.04.2026 г., 16:16
⭐Бе-бе-безумие #овца#sheep#max t.me/addstickers/sheepmax 😊создать свои стикеры
@xinwenchigua8 · Post #66778 · 11.05.2026 г., 14:39
四百块钱,真不贵。。。 8日,新疆伊犁,拉那提景区。。游客带的阿拉斯加犬把小羊咬了,主人赔了四百块钱把羊买下来了。。。 现在好了,不光要养狗,还得养只羊了 #阿拉斯加犬#羊 Four hundred yuan, not expensive at all... On the 8th, in Lanati Scenic Area, Yili, Xinjiang... A tourist's Alaskan Malamute bit a lamb, and the owner paid four hundred yuan to buy it back... Now, not only do you have to keep a dog, you also have to keep a sheep. #AlaskanMala#Sheep
Hashtags
@googlefactss · Post #40711 · 27.02.2026 г., 15:02
Sheep can recognize and remember faces. They can remember 50 sheep faces over two years and at least 10 human faces. They look at outside features first, then focus on eyes, nose, and mouth when familiar. If a sheep stares, it might be memorizing your face! 🐑🧠 @googlefactss #Sheep#SmartAnimals#Faces#Memory#Animals
@googlefactss · Post #40739 · 05.03.2026 г., 15:01
Sheep can feel emotions like fear, anger, boredom, and happiness. They evaluate their surroundings using checks like suddenness, familiarity, predictability, and control, similar to humans. Sudden events can cause fear, while predictable environments may lead to boredom. 🐑⚽️ @googlefactss #AnimalWelfare#Sheep#Emotions#AnimalCare#Nature