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

Резултати

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

Пребарај: #treatyofjassy

当前筛选 #treatyofjassy清除筛选
Russian Embassy in Albania

@rusembalb · Post #6497 · 09.01.2025 г., 21:16

#HistoryOfDiplomacy 📜 On January 9, 1792 (December 29, 1791), the Treaty of Jassy was signed between Russia and the Ottoman Empire, ending the Russian-Turkish war of 1787-1791. That conflict had been provoked by the revanchist policy pursued by the Porta (Ottoman Empire) which sought regaining Crimea and undermining Russia's increasing dominance in the South Caucasus. ⚔️ The 1787-1791 military campaign, which took place in the Northern Black Sea region, the Balkans and the Caucasus, was the triumph of theRussian army. On December 17, 1788, the Russian forces, commanded by Prince Grigory Potemkin victoriously took the fortress of Ochakov, an important stronghold of the Ottoman Empire in the Northern Black Sea region. On December 22, 1790, the Russian army, led by legendary General Alexander Suvorov took the key stronghold of the Porte in the Balkans — Izmail. On July 31, 1791, Admiral Fyodor Ushakov’s fleet decisively crushed the Ottoman navy forces at Cape Kaliakra (the Black Sea). In summer of 1791, Prince Nikolay Repnin, the Commander-in-Chief of the Russian army, negotiated the terms of truce with the Ottomans in Galati. However, after the Parties reached agreement, Russia and the Porte launched talks in Jassy (Iași) in the Moldavian Principality (now Romania). The Russian delegation at the talks headed by Prince Grigory Potemkin. The Ottomans, still hoping to turn the tide of the campaign and defeat the Russian fleet in the Black Sea, tried to protract the negotiations. But those hopes were never destined to come true. The convincing victory of the Russian fleet at Cape Kaliakra forced the Ottoman Empire to cease the hostilities and resume talks. ✍️ Thus, the #TreatyOfJassy, a document comprising a preamble and 13 articles, was finally signed on January 9, 1792. This document, among other things, confirmed some provisions of the 1774 Treaty of Küçük Kaynarca:the Ottoman Empire had recognised Russia’s sovereignty over the north of the Crimean Peninsula, including the important fortresses of Kerch and Yeni-Kale, which blocked the way from the Azov Sea to the Black Sea. Under the 1774 Treaty, the Ottoman Empire also recognised the independence of the Crimean Khanate, which further led to the accession of the Peninsula to the Russian Empire in 1783. ☝️ It is difficult to overestimate the historical significance of the Treaty of Jassy for Russia. By ending the Russian-Turkish war of 1787-1791, the document finally secured the Northern Black Sea region as part of the Russian Empire. The territory between the Southern Bug and Dniester rivers was also transferred to Russia. In 1794, the city of #Odessa was founded in our country’s new territories. The Treaty of Jassy considerably strengthened Russia’s positions in the Balkans and the Caucasus. Under the document's provisions, the Ottoman Empire renounced its claims to Georgia and, therefore, potential aggression against Georgian territory. In general, the Treaty finally put an end to the Ottoman raids on Russia’s southern frontiers.

Russian Consulate in Cape Town

@rusconct · Post #2139 · 10.01.2025 г., 06:44

#HistoryOfDiplomacy 📜 On January 9, 1792 (December 29, 1791), the Treaty of Jassy was signed between Russia and the Ottoman Empire, ending the Russian-Turkish war of 1787-1791. That conflict had been provoked by the revanchist policy pursued by the Porta (Ottoman Empire) which sought regaining Crimea and undermining Russia's increasing dominance in the South Caucasus. ⚔️ The 1787-1791 military campaign, which took place in the Northern Black Sea region, the Balkans and the Caucasus, was the triumph of theRussian army. On December 17, 1788, the Russian forces, commanded by Prince Grigory Potemkin victoriously took the fortress of Ochakov, an important stronghold of the Ottoman Empire in the Northern Black Sea region. On December 22, 1790, the Russian army, led by legendary General Alexander Suvorov took the key stronghold of the Porte in the Balkans — Izmail. On July 31, 1791, Admiral Fyodor Ushakov’s fleet decisively crushed the Ottoman navy forces at Cape Kaliakra (the Black Sea). In summer of 1791, Prince Nikolay Repnin, the Commander-in-Chief of the Russian army, negotiated the terms of truce with the Ottomans in Galati. However, after the Parties reached agreement, Russia and the Porte launched talks in Jassy (Iași) in the Moldavian Principality (now Romania). The Russian delegation at the talks headed by Prince Grigory Potemkin. The Ottomans, still hoping to turn the tide of the campaign and defeat the Russian fleet in the Black Sea, tried to protract the negotiations. But those hopes were never destined to come true. The convincing victory of the Russian fleet at Cape Kaliakra forced the Ottoman Empire to cease the hostilities and resume talks. ✍️ Thus, the #TreatyOfJassy, a document comprising a preamble and 13 articles, was finally signed on January 9, 1792. This document, among other things, confirmed some provisions of the 1774 Treaty of Küçük Kaynarca:the Ottoman Empire had recognised Russia’s sovereignty over the north of the Crimean Peninsula, including the important fortresses of Kerch and Yeni-Kale, which blocked the way from the Azov Sea to the Black Sea. Under the 1774 Treaty, the Ottoman Empire also recognised the independence of the Crimean Khanate, which further led to the accession of the Peninsula to the Russian Empire in 1783. ☝️ It is difficult to overestimate the historical significance of the Treaty of Jassy for Russia. By ending the Russian-Turkish war of 1787-1791, the document finally secured the Northern Black Sea region as part of the Russian Empire. The territory between the Southern Bug and Dniester rivers was also transferred to Russia. In 1794, the city of #Odessa was founded in our country’s new territories. The Treaty of Jassy considerably strengthened Russia’s positions in the Balkans and the Caucasus. Under the document's provisions, the Ottoman Empire renounced its claims to Georgia and, therefore, potential aggression against Georgian territory. In general, the Treaty finally put an end to the Ottoman raids on Russia’s southern frontiers.