Один из самых удобных способов записать данные это использование готовых форматов, такие как 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
⛳International Golf Day on 15 June
📍 Marriott International Corporation is holding its annual International Charity Golf Day in Bali. This year's event will be held on 15 June at the National Golf Club in Nusa Dua.
🏌️♀️ Everyone can join this elite and expensive game, not only through participation in tournaments, but also during the evening programme, which the organisers announce as a kind of networking.
🎷 The festive evening will take place at the Westin Resort Nusa Dua at 18:30 the same day. Everyone is welcome to attend. The dinner will feature a buffet of international cuisine with beer, wine and soft drinks. In addition, guests can expect door prizes, auctions, and an entertainment programme with live music.
@BaliNews
#wheretogo#events#NusaDua
🎾Tennis in Bali: Nusa Dua opens clubhouse for ATP level tournaments
📍 The Bali Golf and Racket Club has opened in Nusa Dua, ready to host ATP tournaments in the future. It is the newest sports complex located in the heart of one of Bali's most prestigious resort areas, The Nusa Dua, which is famous for its five-star hotels and unique infrastructure.
🏆 The club was the first of its kind on the entire island. With its appearance, Bali acquires the status of not only a paradise island, but also a center for international tennis tournaments and sports tourism.
@BaliNews
#goodnews#sport#NusaDua
🎶TGIF 2025 music festival will return to Bali in May
The event promises to be one of the highlights of the music season in Bali.
📆 May 24-25
📍 At a new venue in Port of Benoa
ℹ️ In addition to concerts and live music, guests can expect food courts from local businesses, photo zones, interactive entertainment and relaxation areas. Parking and shuttles to shuttle guests are available for convenience.
🎫 Tickets are on sale now: one-day, two-day and VIP packages are available on the official website from Rp 150.000.
#events#festivals#wheretogo#NusaDua@BaliNews
🛎The first Waldorf Astoria hotel opens in Bali: second attempt
📰 The Hilton hotel group is expanding its presence in Bali. Waldorf Astoria Bali will be located between the Hilton and Kempinski hotels in Nusa Dua, 14.5 km from Ngurah Rai International Airport. The hotel is scheduled to open in late 2027.
🏨 Waldorf Astoria Bali will include 71 spacious villas and 68 guest suites, as well as the standard infrastructure for a chain hotel — restaurants, a spa, a fitness center, children's entertainment, and event rooms.
ℹ️ Waldorf Astoria had already announced the opening of its hotel in Bali in 2014. At that time, the location was chosen near Pandawa Beach in the south of the island. The opening was planned for 2027, but something went wrong. The massive concrete unfinished building can still be seen on the cliff to the left of the entrance to Pandawa Beach.
#places#realestate#development#NusaDua@BaliNews
🚤New Bali water taxi service launches for tourists
📰 A new marine transportation service, Bali Marine Water Taxi, has been launched in the popular resort area of Benoa (Nusa Dua) in Bali.
📍 The tourist cab service connects the seaports of Tanjung Benoa, Serangan and Pedungan (South Denpasar).
35 minutes. That’s all it takes. No traffic, no stress - just ocean views and open horizons. Uluwatu is calling.
👍 This is just one of the many sea routes Bali plans to develop in the coming months.
@BaliNews
#goodnews#places#services#transport#tourism#NusaDua
🛣Details about the construction of a district road in Bukit
District authorities are set to solve the road issue in Uluwatu by laying a new district road.
Construction of the first section from Siligita village to Sawangan in Nusa Dua district has already started.
The original idea was to extend the toll road, which now runs from the airport to Nusa Dua, all the way to Uluwatu.
Right now, traffic on the main road jl. Uluwatu is difficult because it is both a hub of commerce and the main thoroughfare of the area, used by everyone from locals to construction vehicles and tour buses.
The land acquisition budget for 2024 will be $16 million, with the next one already promised to increase to $19 million.
According to an insider in Bali's land office, all consideration of new housing development in the green zone on Bukit is now halted just in time for the land acquisition for the new roads.
@BaliNews
#roads#roads#authorities#Bukit#Uluwatu#NusaDua