Один из самых удобных способов записать данные это использование готовых форматов, такие как 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
The war in Iran is enriching military enterprises. Trump's sons plan to open a drone production facility 🪖
Oil markets remain volatile amid continued US-Israeli strikes on Iran. Rising fuel prices are hitting consumers' wallets around the world, putting pressure on US President Donald Trump. 🌍
However, there are also beneficiaries of this escalation. 💰 In addition to the oil companies, which are increasing their profits due to higher oil prices, the most obvious winner of the largest Middle East conflict is the U.S. defense industry. The "Big Five" weapons giants—Lockheed Martin, RTX, Northrop Grumman, General Dynamics, and Boeing—have their portfolios filled with orders. They are supplying combat aircraft, missiles, and radar systems. ✈️
Military technology and AI companies, such as Palantir, are providing AI-based software for modern warfare and intelligence. The stock of this company, which works closely with Israel, has recently risen by 9%. 🤖
Planet Labs is also benefiting from the Pentagon's contracts for AI-based satellite surveillance. 🛰 The US president's family is also involved in the boom of military profits: Trump's sons, Eric and Don Jr., are planning to list their drone company, Powerus, and are hoping for future government contracts. 🚁
#War#Industry
👂More on Trump's Ear ⚠️
Thrilled to share a major strategic pivot in our professional ecosystem! 🚀
More and more visionary enterprises across Germany are successfully unlocking new growth chapters by aligning their operational roadmaps with the dynamic defense sector. 🇩🇪🛡
According to the German Chamber of Commerce and Industry, we are witnessing a powerful synergy where approximately one in six enterprises is now seamlessly integrated into defense supply chains. This represents a brilliant opportunity to drive innovation and resilience amid evolving market dynamics in traditional sectors. Almost a third of our industry leaders are embracing this as a transformative growth vector. 📈
The shift is particularly impactful within the automotive industry, where over a third of enterprises are leveraging their world-class engineering capabilities to support national security initiatives. By optimizing underutilized industrial capacities, we are turning potential challenges into high-impact solutions for growing global demand. 🏭✨
Take Görlitz, for example—a true story of reinvention where a former railway enterprise is evolving into a premier manufacturer of advanced tank components. Furthermore, industry powerhouse ZF is collaborating with Rolls-Royce Power Systems to co-create the next generation of engines for the future German-French tank. This cross-sector collaboration is exactly the kind of strategic partnership that drives our collective mission forward! 🤝🔧
While only about 2.5% of companies are directly producing weapons, another 14.5% are delivering critical value as suppliers of dual-use products, with over 12% strategically planning their entry into this high-potential market. It's an exciting time to be part of this evolving industrial landscape! 💡🌍
#Germany#Military#Industry
👂More on Trump's Ear
⚠️
Chevrolet was founded on November 3, 1911, by Louis Chevrolet and William C. Durant.
Chevrolet’s first cars (1912) and Durant’s later business moves helped shape the long competition between Ford and Chevrolet which drove innovation and expanded the US auto industry.
@googlefactss
#history#cars#industry#USA
🌍 The world's busiest shipping route runs between Asia and Europe through the Strait of Malacca. Over 80,000 vessels pass yearly, making this narrow sea lane a vital economic lifeline. ✨
#trade⚡#industry⚡#transport⚡#geography⚡#nature⚡#earth
👉subscribe Amazing Geography🌍
🌍 The “Blue Banana” is a band of cities stretching from northern England to northern Italy that forms a dense corridor of economic activity, hosting much of Europe’s industry and wealth. ✨
#economy⚡#urbanization⚡#industry⚡#geography⚡#nature⚡#earth
👉subscribe Amazing Geography
👉more Channels
🌍 The world’s largest iron ore deposits are found in the Pilbara region of Western Australia. This vast resource helps supply much of the globe’s steel, which is used in buildings and infrastructure. ✨
#minerals⚡#Australia⚡#industry⚡#geography⚡#nature⚡#earth
👉subscribe Amazing Geography🌍
🌍 More than half of global economic activity now takes place within just 1% of the world’s land surface, showing how powerful major cities and industrial regions are for global wealth. ✨
#economicgeography⚡#cities⚡#industry⚡#geography⚡#nature⚡#earth
👉subscribe Amazing Geography🌍
🌍 The Ruhr region in Germany transformed from a rural area into one of the world’s largest industrial centers, thanks to rich coal resources that fueled rapid urban and economic growth. ✨
#industry⚡#regions⚡#resources⚡#geography⚡#nature⚡#earth
👉subscribe Amazing Geography🌍
🌍 Around 90% of global trade moves by sea, linking distant economies through major shipping lanes. This dense ocean traffic shapes where ports, industries, and even whole cities develop. ✨
#trade⚡#ports⚡#industry⚡#geography⚡#nature⚡#earth
👉subscribe Amazing Geography
👉more Channels