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

Резултати

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

Пребарај: #fastfood

当前筛选 #fastfood清除筛选
Dishes.Cooking.Food

@cookingdish · Post #940 · 01.09.2025 г., 13:05

Burger! 🍔🤤 Ingredients: For Burger: * Ground beef * Salt/Pepper to taste * Lettuce * Onion * Vinegar * Hamburger buns * American cheese For the Sauce: * Ketchup * Mayonnaise * Mustard * Pickle For Potatoes: * Potato * Garlic powder * Salt/Pepper * Paprika * Olive oil #fastfood @dishes

Hashtags

Dishes.Cooking.Food

@cookingdish · Post #937 · 29.08.2025 г., 13:04

Vegetarian Burger! 🍔🤩 Ingredients: For Burger: * Pumpkin Hummus * Spinach * Tomato * Avocado * Red onions * Aioli For the Cutlet: * 90 g. Soy granules * 4 Beets * 100 g. Flour * 150 g. Oats * 1 tbsp Smoked paprika spice * 2 tsp Salt * 2 tsp Cumin * 1 tsp Pepper * 1 tsp Thyme * 1 tsp Rosemary #fastfood @dishes

Hashtags

Dishes.Cooking.Food

@cookingdish · Post #918 · 11.08.2025 г., 13:05

Filet Mignon with Mushroom Sauce 1️⃣Filet Mignon 🧂 Pinch of Salt 🫒 2 Tbs Olive Oil 🧈 2 Tablespoons Unsalted Butter 🧄 2 Cloves Garlic 🌿 1 Sprig fresh Rosemary 🌿 2 Sprigs fresh Thyme 🥦Asparagus 🍄For Mushroom Sauce: 🫒 Olive oil 🧈 2 Tbsp Butter 🍄 100g Shiitake Mushrooms 🧅 1 Shallot Onion 🥃 1/4 cup Bourbon 🥛 1 cup Heavy Whipping Cream 🧂/🧑‍🍳 Salt/Pepper #fastfood @dishes

Hashtags

Dishes.Cooking.Food

@cookingdish · Post #916 · 09.08.2025 г., 11:04

Pan-Fried Branzino with Anchovy Butter ◇ Ingredients: - 🐟 1 Whole Branzino, filleted into 2 halves - 🐟 Anchovies, finely chopped - 🌿 Fresh Parsley, chopped - 🧈 Butter - 🫒 Olive Oil - 🧵 Kitchen Twine - 🥄 Fresh Asparagus - 🍋 Lemon juice #fastfood @dishes

Hashtags

Dishes.Cooking.Food

@cookingdish · Post #915 · 08.08.2025 г., 13:03

Gnocchi ◇ Ingredients: 🥔 1 kg russet potatoes 🍚 2 cups all-purpose flour, plus extra for dusting 🥚 2 egg yolks 🧄 Garlic For sage butter sauce: 🧈 100g unsalted butter 🌿 10-12 fresh sage leaves 🧂 Salt and freshly ground black pepper, to taste 🧀 Grated Parmesan cheese, for garnish #fastfood @dishes

Hashtags

Dishes.Cooking.Food

@cookingdish · Post #913 · 05.08.2025 г., 11:01

Mushroom Ravioli For the Pasta Dough: 🍝 200g. Semolina 🍝 200g. 00 Flour 🥚 5 large eggs For the Filling: 🧀 200g. ricotta cheese 🍄 400g. finely chopped mushrooms 🧅 1/2 large yellow onion, minced 🧀 2 Tbsp grated Parmesan cheese 🌿 1 Tbsp chopped fresh parsley 🧂 Salt and pepper, to taste 🧈 Butter #fastfood @dishes

Hashtags

Dishes.Cooking.Food

@cookingdish · Post #894 · 16.07.2025 г., 12:38

Big Mac Tacos! 🌮🌮🌮 Ingredients: * Mini wraps * Minced * Salt/Pepper * Pickles * Cheddar * Cabbage * Red onion Sauce: * 2 tbsp Mayo * 1 tbsp Ketchup * 1 Pickle * 1 tsp Yellow mustard * 1/2 tsp Paprika * 1/2 tsp Garlic powder * 1/2 tsp Pepper * 1/2 tsp Onion powder #fastfood @dishes

Hashtags

Dishes.Cooking.Food

@cookingdish · Post #886 · 07.07.2025 г., 21:23

🇬🇧Ingredients for Caesar Salad Tacos 🌿For the Herb Butter: - 🌿 1 handful of parsley - 🌶 1/2 tsp chili flakes - 🧄 1 clove of garlic - 🧈 100 g butter 🌿For the Tacos: - 🌮 4 small wraps - 🧀 Vegan sprinkle cheese - 🌱 4 Green Mountain vegan fillets - 🥬 1 romaine lettuce 🌿For the Salad Dressing: - 🌿 1 tbsp mustard - 🥛 110 g vegan mayo - 🍷 1 tbsp white wine vinegar - 🍋 2 tbsp lemon juice - 🛢 1 tbsp olive oil - 🧂 Salt and pepper to taste #fastfood @dishes

Hashtags

Dishes.Cooking.Food

@cookingdish · Post #878 · 30.06.2025 г., 11:02

Hummus Ingredients: 🥫 230 grams of dried chickpeas 🥄 1/2 tsp baking soda 🧂 1 tsp salt 🥄 180g tahini 🍋 Juice of half a lemon 🧄 2 garlic cloves 1 tsp cumin 🌿 🧂 Salt and pepper to taste 🧊 2-3 Tbsp Ice water Toppings: roasted garlic 🧄, smoked paprika 🌶, parsley 🌿, olive oil 🫒 #fastfood @dishes

Hashtags

Dishes.Cooking.Food

@cookingdish · Post #877 · 29.06.2025 г., 11:04

Fondant Potatoes Ingredients: 🥔 4 large russet potatoes 🫒 2 tablespoons olive oil 🧈 6 tablespoons unsalted butter 🧄 1 garlic head 🌿 6 sprigs fresh thyme 🍗 2 cups chicken broth 🍚 Caviar 🧂 Salt and freshly ground black pepper to taste #fastfood @dishes

Hashtags

Dishes.Cooking.Food

@cookingdish · Post #876 · 28.06.2025 г., 11:02

Fig & Triple Spread Toast Ingredients 🍞 Sourdough bread 🧀 Gorgonzola with Mascarpone 🍇 Raspberry jam 🌰 Pistachio paste Thyme #fastfood @dishes

Hashtags

Dishes.Cooking.Food

@cookingdish · Post #874 · 26.06.2025 г., 11:03

Seared Tuna with Mango Salsa🐟🥭 Ingredients - Tuna Steak 🐟 - Salt 🧂 - Oil 🫒 For the Mango Salsa - 1 ripe mango, diced 🥭 - 1/4 cup red onion, finely chopped 🧅 - 1/3 cup tomato, finely chopped 🍅 - 2 tbsp fresh cilantro, chopped 🌿 - Juice of 1/2 lemon or lime 🍋 - 1/4 cup Ponzu sauce 🍶 - Sesame seeds 🌱 #fastfood @dishes

Hashtags

123•••56
ПретходнаСтраница 1 од 6Следна