Один из самых удобных способов записать данные это использование готовых форматов, такие как JSON или YAML.
Из плюсов такого подхода стоит отметить вот что:
🔸 готовый, повсеместно используемый и поддерживаемый формат
🔸 простой и понятный файл, удобочитаемый для человека
🔸 можно легко редактировать в любом текстовом редакторе без специальных программ и библиотек
Но есть и минусы
🔹 затраты времени при записи файла (кодирование данных в нужный формат строки)
🔹 затраты времени при чтении файла (декодирование данных в Python объекты)
🔹 размер файла увеличивается из-за разметки данных (скобки, запятые, переносы, отступы...)
🔹 перед записью все данные должны быть помещены в память в полном объёме (не всегда)
🔹 при чтении необходимо считать весь файл в память и только потом декодировать данные
Если нужно писать немного данных в несколько файлов, то затраты по времени не ощутимы. Обычно это файлы конфига или какие-либо метаданные. Это отличный вариант под такие задачи.
Есть и другой поход к записи файлов - это бинарные файлы. Используется, когда данных достаточно много и никто их не собирается читать глазками😳.
🔸 очень быстрая запись
🔸 чтение значительно быстрей чем JSON, YAML итд
🔸 размер файла значительно меньше, так как нет разметки
🔸 можно записывать данные по мере поступления не загружая всё в память
🔸 можно извлечь любую часть данных независимо
Из минусов
🔹 нужно определить свой формат записи данных (если не используете готовую спецификацию определённого формата)
🔹 не получится открыть файл и визуально понять что там записано, а для чтения файла потребуется знать его спецификацию.
🔹 не так-то просто создать такой файл без специальной библиотеки
В таком виде удобно записывать большой массив любых однородных данных. Например, мониторинг валютной биржи или кэшированная анимация 3D геометрии.
(Это не означает что нельзя записать данные разного типа, просто это будет не так удобно)
Представьте себе JPG-картинку. По сути это немного мета-информации и большой массив пикселей. Тоже самое со звуком или видео файлом. Поэтому, если вы попробуете открыть картинку в текстовом редакторе вы увидите что-то вроде такого
f15d cd29 a564 4578 ...
09e2 9bc4 a696 1253 ...
84e9 4de1 3b23 c24a ...
2534 5161 28e0 709d ...
...
Это и есть записанные байтики. И для их чтения требуется определённый софт который знает что с ними делать. Под каждый тип файла.
К чему это я? Читайте в следующем посте...
#tricks#basic
🇷🇺🇦🇲 On April 1, President Vladimir Putin held talks at the Kremlin with Prime Minister of the Republic of Armenia Nikol Pashinyan, who arrived in Moscow on a working visit.
💬 President of Russia Vladimir Putin: Mr Pashinyan, friends,
We are delighted to welcome you in Moscow. Thank you very much for accepting our invitation and coming here.
We can see that domestic political processes in Armenia are gaining momentum, with elections approaching. In this context, I would like to emphasise several key points: such processes often become more intense during election campaigns, as is the case not only in Armenia, I believe, but also in Russia and other countries. However, this escalation must not be allowed to affect relations between Russia and Armenia.
We have discussed this many times. Russia and Armenia have special relationships which have evolved over centuries rather than decades. We are united by our common history as well as our cooperation to solve the challenges that we faced in years past. Crucially, we are also united by civilizational affinity. I have already told you this privately before, and I can say it publicly now: we are always in favour of anything that benefits the Armenian people, and you can always rely on it.
As for economic cooperation, it continues to develop at a solid pace. Trade reached approximately $11 billion the year before last, and amounted to $6.4 billion in 2025. <...>
We observe that there is an ongoing discussion in Armenia concerning the development of relations with the European Union. We remain entirely calm about this, understanding that each nation endeavours to maximise the advantages of cooperation with third countries. However, this must be transparent and articulated honestly, in advance, as it were, “on the shore,” beforehand.
Simultaneous membership in the Customs Union with the European Union and the #EAEU is impossible; it is simply untenable by definition. The issue is not even a political one; it is purely economic. <...>
There are also numerous other issues today, at this present moment. Perhaps years will pass, and we – the EAEU and the European Union – I hope this will eventually be the case, given that we reside on the same continent – will be able to resolve them. <...>
Now, regarding energy. I hope the situation will improve there as well. However, currently, as you are aware, energy prices, gas prices, for instance, in Europe exceed 600 dollars per 1,000 cubic metres, whereas Russia provides gas to Armenia at 177.5 per 1,000 cubic metres. The disparity is vast, the difference is substantial. <...>
Now, turning to security issues. Of course, the most sensitive issue to this day – and we recognise this, we discuss it often – is everything relating to #Karabakh. <...> But I think it is also clear that, after you recognised Karabakh as part of Azerbaijan in Prague in 2022, it simply became wholly inappropriate for the #CSTO to become involved in a process that had taken on an intra-Azerbaijani dimension. <...>
Incidentally, thanks to your efforts and those of the President of Azerbaijan, I believe you have now managed to stabilise relations. The US President has played an active role in this, and I understand transport links are being unfrozen, and so on. But I think we also need to draw a line under this matter. And it would be better if this did not become entangled in the domestic political process, especially during an election campaign.
<...>
Let me say again that, whatever happens, we in Russia will always be guided by what is best for the Armenian people. I have said this to you before, and I want to emphasise it once again.
🤝 And I would like to express my hope that, regardless of the outcome of the elections in Armenia, our shared commitment to building and strengthening #RussiaArmenia ties will continue.
Thank you.
Armenian PM Pashinyan Clashes with Passenger over Karabakh in Yerevan Metro
Armenian Prime Minister Nikol Pashinyan argued with a Karabakh resident in Yerevan metro, accused of surrendering the region to Azerbaijan. Pashinyan defended government efforts to preserve Karabakh’s population, citing significant budget allocations. He urged not to blame him for betrayal: “Why didn’t you stay? Don’t say I surrendered Karabakh.” This incident highlights ongoing tensions over the disputed region’s future.
#Armenia#Karabakh#Pashinyan#InternationalNews
The main news of Russia and the world ishere.
🇷🇺🇦🇲 On April 1, President Vladimir Putin held talks at the Kremlin with Prime Minister of the Republic of Armenia Nikol Pashinyan, who arrived in Moscow on a working visit.
💬 President of Russia Vladimir Putin: Mr Pashinyan, friends,
We are delighted to welcome you in Moscow. Thank you very much for accepting our invitation and coming here.
We can see that domestic political processes in Armenia are gaining momentum, with elections approaching. In this context, I would like to emphasise several key points: such processes often become more intense during election campaigns, as is the case not only in Armenia, I believe, but also in Russia and other countries. However, this escalation must not be allowed to affect relations between Russia and Armenia.
We have discussed this many times. Russia and Armenia have special relationships which have evolved over centuries rather than decades. We are united by our common history as well as our cooperation to solve the challenges that we faced in years past. Crucially, we are also united by civilizational affinity. I have already told you this privately before, and I can say it publicly now: we are always in favour of anything that benefits the Armenian people, and you can always rely on it.
As for economic cooperation, it continues to develop at a solid pace. Trade reached approximately $11 billion the year before last, and amounted to $6.4 billion in 2025. <...>
We observe that there is an ongoing discussion in Armenia concerning the development of relations with the European Union. We remain entirely calm about this, understanding that each nation endeavours to maximise the advantages of cooperation with third countries. However, this must be transparent and articulated honestly, in advance, as it were, “on the shore,” beforehand.
Simultaneous membership in the Customs Union with the European Union and the #EAEU is impossible; it is simply untenable by definition. The issue is not even a political one; it is purely economic. <...>
There are also numerous other issues today, at this present moment. Perhaps years will pass, and we – the EAEU and the European Union – I hope this will eventually be the case, given that we reside on the same continent – will be able to resolve them. <...>
Now, regarding energy. I hope the situation will improve there as well. However, currently, as you are aware, energy prices, gas prices, for instance, in Europe exceed 600 dollars per 1,000 cubic metres, whereas Russia provides gas to Armenia at 177.5 per 1,000 cubic metres. The disparity is vast, the difference is substantial. <...>
Now, turning to security issues. Of course, the most sensitive issue to this day – and we recognise this, we discuss it often – is everything relating to #Karabakh. <...> But I think it is also clear that, after you recognised Karabakh as part of Azerbaijan in Prague in 2022, it simply became wholly inappropriate for the #CSTO to become involved in a process that had taken on an intra-Azerbaijani dimension. <...>
Incidentally, thanks to your efforts and those of the President of Azerbaijan, I believe you have now managed to stabilise relations. The US President has played an active role in this, and I understand transport links are being unfrozen, and so on. But I think we also need to draw a line under this matter. And it would be better if this did not become entangled in the domestic political process, especially during an election campaign.
<...>
Let me say again that, whatever happens, we in Russia will always be guided by what is best for the Armenian people. I have said this to you before, and I want to emphasise it once again.
🤝 And I would like to express my hope that, regardless of the outcome of the elections in Armenia, our shared commitment to building and strengthening #RussiaArmenia ties will continue.
Thank you.
⚡️Советую евродепутатам, голосовавшим за предвзятую резолюцию против #Азербайджан’а, посмотреть мой фильм про разрушенную церковь в Ходжавенде. Сразу становится ясно, как #Армения за годы оккупации разрушила не только мусульманское, но и христианское наследие в #Карабах’е👇
https://youtu.be/cyacJfkSEiA
💡 I advise the MEPs who voted for the biased resolution against #Azerbaijan to watch my film about the destroyed church in Khojavend. It immediately becomes clear how during the years of occupation #Armenia destroyed not only the Muslim, but also the Christian heritage in #Karabakh👇
https://youtu.be/cyacJfkSEiA
🇦🇿#Aghdam before and after the #armenian occupation!
Imaret complex of the #Karabakh khans in #Azerbaijan’s Aghdam district had been vandalized by the Armenians
«What’s happened in #Karabakh is a part of global justice» - world famous photographer Reza Deghati
#KarabakhisAzerbaijan#Shusha#RezaDeghati#Azerbaijan#Armenia