Один из самых удобных способов записать данные это использование готовых форматов, такие как 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
Does this vibrant walkway look familiar?
Once just a canal, it's now a bustling pedestrian mall along Orchard Road!
Open spaces, art installations, and alfresco dining showcase how urban design transforms infrastructure into lively community hubs.
Uncover more behind-the-scenes stories about how urban design has shaped Singapore over the last 50 years
👉🏻go.gov.sg/UDPlanstoRealityTG
#UrbanDesign
🤔 Have you seen this staircase at Upper Thomson Road on your social media feed?
More than just a photogenic spot, it is the result of a community effort led by Joanne Teh, a resident at Yew Lian Park, who wanted to make the pathway safer and more attractive for everyone to use and enjoy.
If you have an idea to enhance and enliven the spaces around you, apply to get up to $20,000 from the Lively Places Fund for your initiatives!
Find out more
👉go.gov.sg/LivelyPlacesFundTG
#UrbanDesign#LivelyPlacesFund
Singapore’s hot weather can be a bother if you take a stroll at Marina Bay. But with our solar-powered breeze shelters strategically placed along the promenade, you don’t need no Oppas to shelter you from the heat! 🌬
#UrbanDesign#DiscoverSingapore#MarinaBay
A bunch of postcards just arrived in the mail for you! 💌
We’re working on a Recreation Master Plan to make way for more leisure opportunities. For the Central Area of Singapore, there are plans to enhance the attractiveness of the community space at Sultan Gate, improve the walk-cycle connectivity along the Inner Ring Corridor and more!
Want to help shape these spaces and other recreational spots in this region?
Share your best ideas with us here:
👉go.gov.sg/CentralAreaRecreTG
#DMP2025#RecreaMP#ExploreSingapore#Recreation#UrbanDesign#SpaceForOurDreams
Love the vibes at Holland Village? We do too 🙌
From low-rise buildings to continuous walkways and elegant signages, find out how we’re retaining the unique charm and familiar identity of the area through thoughtful planning and design.
#HollandVillage#ExploreSingapore#UrbanDesign#IdentityNode#SGHeritage
Can you picture a car-lite future for Singapore? With more cycling paths being built, it could soon be a reality!
The Bishan-to-City (B2C) Link is one of the pathways made possible by planners like Syafie, along with feedback from citizens like you, to make the island more connected and accessible for everyone. Watch on to learn more about his role and why he loves it.
Want to shape our city too? Explore career opportunities with URA now 👉http://go.gov.sg/URA-CareersSyafieTG
Also, learn more about our efforts to create a car-lite and sustainable city on our free guided community tours: http://go.gov.sg/ura-wcfd24
#UrbanDesign#URASingapore#DiscoverSingapore#Hiring#UrbanPlanning#WCFDsg#WorldCarFreeDay
The Shanghai Lingang Special Area master plan.
Design: Ennead Architects
Location: Shanghai, China
Ennead Architects has designed the Shanghai Lingang Special Area master plan (a new hub for global commerce) around the central axis that defines the Dishui Lake district in Shanghai.
One of the key features of the Shanghai Lingang Special Area will be “The Ring”. This circular, cantilevered observation deck, and museum will afford 360-degree views of nearby Dishui Lake, Shanghai and the Pacific Ocean.
The two towers flanking the Ring (The Tower Waterfall and Tower Rhomboid) are designed to become two of the most easily recognizable features of the new business district. Similar in scale, the towers have distinct identities.
#Architecture#arch_shovel#NewsArchitecture#News#Shanghai#China#Masterplan#CityPlanning#OfficeBuilding#CommercialArchitecture#UrbanDistrict#UrbanDesign