Один из самых удобных способов записать данные это использование готовых форматов, такие как 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
🚗💨 Introducing the track-ready Cadillac CT5-V! 🎉
This powerful beast now features a Precision Package with enhanced suspension, including increased stiffness and reprogrammed adaptive dampers for an exhilarating ride on the track! 🏁✨
🔧 Key Highlights:
- Carbon-Ceramic Brakes for superior stopping power 🛑
- 6.2L V8 Engine producing an impressive 677 hp and 892 Nm of torque 💪🔥
- RWD for that ultimate driving experience!
Get ready to unleash the power! 💥
#CadillacCT5V#PrecisionPackage#TrackReady#V8Power#Auto
🚗✨Lexus Unveils Upgraded LC Coupe and Convertible!✨🚗
Since its debut in 2017, the Lexus LC family has received a sleek exterior makeover and new interior materials. But that's not all! The updated models now feature a stiffer chassis, thanks to additional braces installed under the floor near the front and rear axles, enhancing overall handling. 🏎️💨
Under the hood, the Lexus LC offers a powerful lineup: a 5.0L V8 engine producing 477 hp or a hybrid V6 powertrain with a 3.5L engine delivering 359 hp. 🔥🔋
#LexusLC#LuxuryCars#CarEnthusiast#DrivingExperience#AutoNews#V8Power#Auto
🌟 Exciting News for Supercar Enthusiasts! 🚗💨
The British have officially kicked off production of the stunning Ginetta Akula! 🦈✨
First unveiled in 2019, this masterpiece is limited to just 20 units, starting at £275,000. 💰
Featuring a classic design, the Akula boasts a powerful 6.4L V8 engine with 600 hp, paired with a manual transmission and rear-wheel drive. 🔥 Despite its robust engine, it weighs only 1.2 tons, accelerating from 0 to 100 km/h in just 2.9 seconds! ⚡️🏁 With a top speed of 290 km/h, this beauty is ready to roar!
Are you ready to experience the thrill? 😍
#GinettaAkula#Supercar#LimitedEdition#V8Power#CarEnthusiast#LuxuryCars#SpeedDemon#Auto
🚗💨 Introducing the BMW M5 Touring! 💨🚗
BMW has officially unveiled the stunning M5 in Touring body style!🌟
Under the hood, it boasts a powerful V8 twin-turbo engine with an impressive total output of 727 horsepower!🔥💪
With the rear seats folded down, you can fit a whopping 1.6 cubic meters of cargo! 🧳📦 And it can sprint from 0 to 100 km/h in just 3.6 seconds!⏱️⚡️
Weighing in at 2508 kg, this beauty is slightly heavier than its sedan counterpart. 🚙✨ This is only the third generation of the M5 in this body style and the first to hit the US market! 🇺🇸
Prices start at $121,500.💵
Get ready for an exhilarating ride! 🏁
#BMW#M5Touring#SportsCar#V8Power#LuxuryPerformance#CarEnthusiast#FastCars#Auto#BMWM🚘🌍
🚗💨 Dodge Unveils the "Farewell" Durango SRT Hellcat Silver Bullet! 💨🚗
This stunning special edition is one of the last to feature the powerful 6.2-liter HEMI V8 engine. As we bid farewell to these muscle machines, the Durango will soon lose its mighty motors. 😢💔
The Silver Bullet edition stands out with its exclusive decor and rich standard features, starting at $113,325**—about **$11,000 more than the previous year's base Durango Hellcat! 💰✨
Get ready to say goodbye to an icon!
#Dodge#DurangoSRT#Hellcat#SilverBullet#MuscleCar#Auto#V8Power#SUV🏁🔥
🚗💨 Introducing the Naran Hypercar: The Ultimate Powerhouse! 🌟
Get ready for the unveiling of the Naran Hypercar in the UK this August! 🇬🇧 With a staggering 1000 horsepower, this beast promises to be the fastest four-seater car in the world, powered by a traditional internal combustion engine—no electric enhancements! ⚡️❌
Only 39 units will be produced, making it an exclusive masterpiece! 🎨✨
Under the hood, it features a 5.0-liter twin-turbo V8, derived from BMW's impressive 4.4-liter engine. 🏎️💥 And yes, it comes with full-wheel drive for that ultimate driving experience! 🌍🚀
#NaranHypercar#CarEnthusiasts#AutomotiveExcellence#V8Power#Hypercar#FastestCar#LuxuryCars#CarLovers#InnovativeEngineering
🚗💨 Introducing the Ford F-150 FP700S! 🎉
Get ready for the ultimate asphalt beast! 🔥 With a powerful 700-horsepower V8 engine, this custom pickup is designed for performance and style.
🔧 Key Features:
• Supercharged 5.0L V8 with Whipple blower 💥
• Sporty exhaust system for that perfect roar 🎶
• Lowered suspension with new shocks for enhanced handling 🏎️
• Stunning 22-inch wheels for a bold look 🛞
• Aerodynamic body elements to slice through the air ✈️
#FordF150#FP700S#CustomGarage#PerformanceTruck#V8Power#AsphaltBeast#FordTuning#Auto
🚗✨ Exciting News from Mercedes-Maybach! ✨🚗
Get ready for the debut of the stunning new convertible on August 15th at the prestigious Pebble Beach! 🌊🏖️
The highly anticipated model has been teased since 2022, and we can't wait to see it in all its glory! 🤩
🔍 Fuel Efficiency: The Mercedes-Maybach SL boasts an impressive fuel consumption of 13.7 liters per 100 km*, closely matching the non-hybrid Mercedes-AMG SL 63 with its powerful 4.0L V8 engine, delivering a thrilling 585 hp and 800 Nm* of torque! 💨🔥
#MercedesMaybach#Convertible#LuxuryCars#PebbleBeach#CarDebut#FuelEfficiency#AMG#V8Power#Auto
🚗✨ Introducing the all-new AC Cobra GT Coupe! 🌟
For the first time in history, this iconic sports car is getting a hardtop version, and it's set to be produced in series! 🏁💨
With stunning carbon body panels, the Coupe is not only beautiful but also powerful! 💪🔥 Choose between two roaring V8 engines: 565 or 730 horsepower!
Starting at just £325,000, this masterpiece is ready to hit the roads! 💷🚀
#ACCobra#SportsCar#CarEnthusiast#LuxuryAutomobile#V8Power#CobraGT#CarLovers#IconicDesign#AutomotiveExcellence
🚗💨Introducing the Doughboy: A Mind-Blowing Restomod with 2838 HP!💥
At the SEMA Show, we unveiled a beast that redefines power and performance! 🔥 This incredible V8 engine boasts a staggering 8.8 liters of displacement and is equipped with dual turbochargers, pushing the limits of automotive engineering. 💪✨
🔧 With the engine strategically shifted 40 cm back towards the center of the wheelbase, every detail has been meticulously crafted from scratch, including the intake, exhaust, and cooling systems. 🛠️
💎 Custom parts were expertly created using CNC machining and 3D printing technology, showcasing innovation at its finest.
Get ready to experience the future of restomods! 🚀
#Doughboy#SEMA2023#Restomod#V8Power#Turbocharged#CarEnthusiast#AutomotiveInnovation#CustomCars#CNC#Auto