Один из самых удобных способов записать данные это использование готовых форматов, такие как 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
🇸🇦SAUDI ARABIA
The ancient city of Al-Diryah was the first capital of Saudi Arabia. According to the records in the chronicles of Najd, this is where the oldest ruling family of the country originates from.
In 2010, the central district of Al-Turaif was added to the UNESCO World Heritage List and became an open-air museum.
#SaudiArabia
@voyage
🗺Saudi Arabia🇸🇦
In the ancient oasis of the desert canyons of the Ashar Valley, Saudi Arabia, a stunning eco-resort named Habitas AlUla has opened.
This 5-star resort is nestled among mesmerizing sandstone cliffs and ancient Nabatean settlements, where trade routes passed as early as the 1st century AD.
The eco-resort is located near famous attractions, including the Old Town of AlUla and the mirrored Maraya Concert Hall.
#SaudiArabia
@voyage
🇰🇷🇸🇦Saudi Arabia Pledges Priority Oil Shipments to Seoul
Saudi Arabia has committed to allocating oil shipments to South Korea on a priority basis, Industry Minister Kim Jung-kwan said on April 12. Seoul is working to dispatch five Korean-flagged vessels to the Saudi Red Sea port of Yanbu to establish alternative supply routes after the Strait of Hormuz was effectively closed amid the Middle East conflict.
Kim said the government is preparing to allow South Korean vessels to use the Red Sea route, including the possible deployment of the Cheonghae unit's Dae Joyoung destroyer for escort operations. The ministry is also considering increasing crude oil purchases from the United States and Kazakhstan to diversify import sources.
Oil prices rose following US-Israeli strikes on Iran in late February, adding pressure on South Korea's economy given its heavy reliance on Middle East energy supplies. Kim described securing energy resources as a priority alongside economic considerations.
#SouthKorea#SaudiArabia
@asianomics
📝Russia Seeks Middle East Settlement📝
on RF mediation efforts in Middle East settlement
It is still too early to discuss the peace talks that are supposed to take place in Pakistan (especially since they have not even started yet). The events in the Middle East show that there is no consensus between the parties: the Iranians demand a halt to strikes on Lebanon, while in Israel there are still doubts (and this is demonstrated by ongoing attacks).
Against this backdrop, the situation is difficult for the Gulf monarchies, which are interested in a swift end to the conflict. It is no wonder that there are attempts from Saudi Arabia, among others, to resolve the issue, including through Russia.
🔻What is this about?
▪️In early April, about a month after Vladimir Putin’s conversation with Crown Prince Mohammed bin Salman, a new contact took place. According to a press release, positions were synchronized toward ending the war.
▪️Moreover, this course of events was even proposed by some Russian Muslims: the head of the Spiritual Assembly of Muslims of Russia, Albir Karganov, already in March called for organizing a council to discuss the future of peace at the level of the heads of Muslim countries.
▪️The choice was not accidental, considering that Saudi Arabia hosts religious shrines sacred to Muslims, which annually attract millions of pilgrims. Contacts with Russia regarding the resolution seem very timely.
▪️Especially since in the summer of 2025, during the first war, Mohammed bin Salman supported Iran and advocated for de-escalation of relations with Iran through dialogue and reducing overall regional tensions.
❗️Even from a factual perspective, there is no sign of a desire for peace from the US or Israel. The Americans demand the opening of the Strait of Hormuz and the elimination of the nuclear program, gradually strengthening their military grouping: transport planes are transferring cargo and ammunition, and intelligence continues to diligently monitor Iran.
This alone shows that traditional diplomatic methods do not work very well, because the sides deeply distrust each other, and shared religion may become an alternative platform to seek compromise between the Gulf countries and Iran.
At least, the ground for this exists.
#Iran#Russia#SaudiArabia
💸Support us
@rybar
📝Russia Seeks Middle East Settlement📝
on RF mediation efforts in Middle East settlement
It is still too early to discuss the peace talks that are supposed to take place in Pakistan (especially since they have not even started yet). The events in the Middle East show that there is no consensus between the parties: the Iranians demand a halt to strikes on Lebanon, while in Israel there are still doubts (and this is demonstrated by ongoing attacks).
Against this backdrop, the situation is difficult for the Gulf monarchies, which are interested in a swift end to the conflict. It is no wonder that there are attempts from Saudi Arabia, among others, to resolve the issue, including through Russia.
🔻What is this about?
▪️In early April, about a month after Vladimir Putin’s conversation with Crown Prince Mohammed bin Salman, a new contact took place. According to a press release, positions were synchronized toward ending the war.
▪️Moreover, this course of events was even proposed by some Russian Muslims: the head of the Spiritual Assembly of Muslims of Russia, Albir Karganov, already in March called for organizing a council to discuss the future of peace at the level of the heads of Muslim countries.
▪️The choice was not accidental, considering that Saudi Arabia hosts religious shrines sacred to Muslims, which annually attract millions of pilgrims. Contacts with Russia regarding the resolution seem very timely.
▪️Especially since in the summer of 2025, during the first war, Mohammed bin Salman supported Iran and advocated for de-escalation of relations with Iran through dialogue and reducing overall regional tensions.
❗️Even from a factual perspective, there is no sign of a desire for peace from the US or Israel. The Americans demand the opening of the Strait of Hormuz and the elimination of the nuclear program, gradually strengthening their military grouping: transport planes are transferring cargo and ammunition, and intelligence continues to diligently monitor Iran.
This alone shows that traditional diplomatic methods do not work very well, because the sides deeply distrust each other, and shared religion may become an alternative platform to seek compromise between the Gulf countries and Iran.
At least, the ground for this exists.
#Iran#Russia#SaudiArabia
💸Support us
@rybar
🇾🇪#Yemen – 🇸🇦#SaudiArabia: Footage shows protests that began on April 1st in eastern Yemen, where demonstrators expressing support for the UAE-backed Southern Transitional Council (STC) were fired upon by Yemen’s Homeland Shield Forces.
Several people were killed at the scene, with dozens more injured.
The STC previously condemned such incidents and called on the international community to respond, accusing authorities of ongoing repression in southern regions.
The group, backed by the United Arab Emirates, had previously maintained control over Aden and large parts of southern Yemen before being pushed back earlier this year by forces aligned with the Saudi-backed government(Yemen's Homeland Shield Forces).
(via @KurdishFrontNews)
🇸🇦#SaudiArabia - 🇾🇪#Yemen: Saudi Arabia bombed a shipment of weapons in Yemen’s port city of Mukalla earlier this morning.
The shipment reportedly arrived from the United Arab Emirates and, according to Saudi Arabia, was intended for Southern Transitional Council (STC) forces. The strikes targeted military equipment and vehicles belonging to the STC.
The strike follows an offensive earlier this month by the STC against Yemeni government troops backed by the coalition. The STC was initially part of the Saudi-led coalition that intervened in Yemen in 2015 against the Houthis, but later pursued autonomy in southern Yemen.
(via The Guardian)
🇦🇪#UAE / 🇸🇦#SaudiArabia – 🇮🇷#Iran: The Saudi and UAE Ministries of Defence have released footage showing Iranian drones being intercepted and shot down after entering their airspace in separate incidents.
Top Saudi court hands down death sentence to #Shia activist from Qatif
🔹#SaudiArabia's Specialized Criminal Court has sentenced an anti-regime activist from the kingdom’s oil-rich and Shia-populated Eastern Province to death, as the House of Saud is pressing ahead with a heavy-handed crackdown agains of the religious community.
@skhanzadeh_ir
فناوری برای بشریت
🇰🇷Seoul Secures 273M Barrels Via Alternative Routes
South Korea's presidential chief of staff Kang Hoon-sik announced that the country had secured 273 million barrels of crude oil and 2.1 million tons of naphtha from four nations by year-end, following an eight-day diplomatic mission to Oman, Saudi Arabia, Qatar, and Kazakhstan. Kang stated the crude oil volume is sufficient to sustain the economy for more than three months under normal operating conditions.
Saudi Arabia, South Korea's largest crude supplier, committed to supplying 200 million barrels, including 50 million barrels to be shipped through an alternative Red Sea port between April and May. Qatar, which had previously declared force majeure on its long-term LNG contracts with Seoul due to Iranian missile strikes on its facilities, confirmed it would fulfill its obligations and treat South Korea as a top priority.
All crude oil and naphtha will be routed through alternative shipping lanes not passing through the Strait of Hormuz, which has been effectively closed since the US-Iran conflict began in late February. Kang also said his delegation held discussions on establishing crude oil storage facilities outside the strait, and Oman's Deputy Prime Minister expressed willingness to assist the safe passage of 26 South Korea-related vessels currently stranded there.
#SouthKorea#SaudiArabia#Kazakhstan
@asianomics