Один из самых удобных способов записать данные это использование готовых форматов, такие как 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
🇨🇳🤝🇷🇸Serbian MiG-29B fighters have received Chinese CM-400AKG hypersonic aeroballistic missiles as we reported yesterday, but let's look closer.
Photos have appeared online showing a fighter equipped with two Chinese CM-400AKG air-to-surface missiles. If confirmed, Serbia would become the second foreign operator of this weapon system.
The CM-400AKG is an aeroballistic missile developed on the basis of the SY400 unguided air-launched rocket. Since it weighs only about 910 kg, it can be carried even by light fighters such as the JF-17 Thunder, for which it was originally designed.
It reaches speeds of around Mach 5.5 to 6.3, which effectively makes Serbian MiG-29s the first fighters in Europe outside of Russia to gain hypersonic strike capability. At the current stage, this would put them ahead even of the Rafale F4.1/5 and Rafale-M, which are still awaiting the development and operational readiness of the ASN4G hypersonic missile. Depending on the variant, its strike range is reported to be between 240 and 400 km.
The guidance system includes:
- Inertial and satellite navigation
- Passive radar seeker
- Optionally: an infrared or television guidance channel
Serbia inherited part of its MiG-29 fleet from the Yugoslav Air Force, and later received additional aircraft from Russia and Belarus.
Although the onboard radars of these aircraft already lag well behind modern systems, integrating the CM-400AKG could significantly expand their strike capabilities. When using this missile, targeting data can come from external reconnaissance assets, so the age of the aircraft’s own radar is not a decisive factor.
At the same time, in 2024 Belgrade signed an agreement to purchase French Dassault Rafale fighters, which, according to specialized media reports, will have limited capabilities and will not receive long-range Meteor missiles.
Many link the choice of French aircraft to political factors and Serbia’s desire for closer integration with the European Union.
It is worth noting that Serbia has already purchased Chinese weapons before, for example the HQ-22 air defense system, selected as an alternative to the sanctioned Russian S-300 and S-400 systems.
If the integration of the CM-400AKG is confirmed, it could extend the service life of Serbian MiG-29s and draw the attention of other operators of this fighter, such as Algeria, Myanmar, Belarus, and Turkmenistan.
🤫 It is also noteworthy that, under the current circumstances, the Russian Ministry of Defense could quite plausibly purchase a batch of 300 to 500 CM-400AKG missiles, after which specialists at aircraft repair plants could adapt the weapon control systems of MiG-29S, SMT, M2, and MiG-29K fighters in service with the Russian Aerospace Forces for the use of these missiles in further strikes against AFU targets.
#info
#Mig29#Serbia
#China#Air_to_Air
#radar