Один из самых удобных способов записать данные это использование готовых форматов, такие как 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
✈️Another new international flight
🇦🇺 AirAsia will launch a new Bali to Adelaide (Australia) flight. The flights between Adelaide and Denpasar will commence from June 25 this year, becoming the first low-cost carrier on this route.
ℹ️ The four flights per week will be operated by an A320-200 with a capacity of 180 seats. Passenger traffic at Adelaide Airport is expected to increase to 74,000 people per year once the new route is introduced.
@BaliNews
#tourism#destinations
🇫🇷🇷🇺Thomas Rodriguez, organisateur de voyages à travers la Russie: l'Anneau d'or est une destination incroyable.
J'ai envie de recommander à tous ceux qui veulent venir en Russie de voir l'Anneau d'or. Ce sont des destinations vraiment incroyables parce que c'est juste à côté de Moscou, donc en termes ne serait-ce que d'organisation, c'est beaucoup plus facile. Et il y a des villes qu'on peut visiter en une journée, même en prenant le temps, qui montrent, comme Serguiev Possad, même Kostroma, Yaroslav, toutes ces villes-là sont incroyables, dans le sens où on voit une Russie qui est différente, plus ancienne.
#russie#voyages#destinations
📰Garuda Indonesia launches direct flight between Halim and Bali
✈️ Garuda Indonesia has begun operating daily flights between Halim Airport in Jakarta and Ngurah Rai Airport in Bali. The new route is designed to make travel between the capital and the island faster and more convenient, as well as to relieve congestion at the crowded Soekarno-Hatta Airport.
📍 Halim is located just 12 km from the city center, where most countries' consulates are located and from where passenger trains depart for destinations across the island of Java.
#goodnews#destinations#tourism@BaliNews
🇻🇳 Vietnam Airlines launches direct flights from Ho Chi Minh City to Bali from June
📅 Vietnam Airlines will launch a new direct route between Ho Chi Minh City, Vietnam and Denpasar, Bali from June 1. Flights will operate four times a week.
✈️ There will now be 14 direct flights per week between Vietnam and Indonesia. Currently, flights between Ho Chi Minh City and Bali are operated by VietJet Air. The arrival of the new operator will give travelers more choices and options.
@BaliNews
#goodnews#destinations#tourism
✈️New flights from Bali: Guangzhou, Jeddah, Perth and domestic routes
🇨🇳TransNusa airlines has become the first Indonesian carrier to launch a Bali – Guangzhou (China) flight.
🎫 Tickets for the new flight are on sale at a promotional price of $149.
🇦🇺 Meanwhile, TransNusa also launched a connecting flight between Guangzhou and Perth, Australia.
🇸🇦 And Saudi Airlines announced the arrival of a direct flight from Denpasar to Jeddah.
@BaliNews
#goodnews#destinations#tourism
✈️From Saudi Arabia to Bali by direct flight
📰Saudia Airlines has launched flights from Jeddah to Bali.
🕋Saudia, the national carrier, has officially launched flights between Bali and Jeddah, the “gateway to Mecca” for pilgrims.
ℹ️Saudia Airlines will operate flights from Jeddah to Bali three times a week with a Boeing 787-900 Dreamliner.
@BaliNews
#destinations#tourism#culture
🔤🔤🔤 flights are lanched by Indonesian airlines
✈️Garuda, Lion Air, Citilink and Batik Air have launched new flights.
・Indonesian airline Garuda Indonesia has launched new flights between Denpasar-Balikpapan (Kalimantan) and Balikpapan-Makassar (Sulawesi). This is part of the airline's wider mission to support the development of Indonesia's new capital city of Nusantara.
・Lion Air will fly the Denpasar - Medan (Sumatra) route every Tuesday, Wednesday, Thursday, Friday from December 6, 2024.
・Citilink has launched a flight from Jakarta (Halim Airport) to Wei Kanan (Lampung, Sumatra) from November 20. The flights are operated twice a week – on Wednesdays and Sundays.
・Batik Air started daily flights from Bengkulu (BKS) to Jakarta (CGK) from November 2024. In addition, the company has connected Kuala Lumpur with four Indonesian destinations – Lombok, Surabaya (East Java), Padang (Sumatra) and Pekanbaru (Riau) with direct flights.
@BaliNews
#transport#airport#destinations
🇵🇪 Indonesia opens its doors: Peru granted visa-free travel
📰 Following Brazil and Turkey, Indonesia has added Peru to its list of visa-exempt countries.
🤝 The key factor is reciprocity: Peru already allows Indonesian citizens to visit without a visa. Now, Peruvians enjoy the same privilege for traveling to Indonesia.
#tourism#visa#destinations@BaliNews
🇨🇳 The new Bali to Guangzhou flight details
A convenient connection to Perth and a chance to linger on the island.
✈️TransNusa opens a direct Bali - Guangzhou flight and becomes the first Indonesian carrier on this route! The first flight will take place as early as April 13.
We are pleased to offer this flight and hope that passengers will not just wait for a connection but stay longer in Bali,
said TransNusa.
Why it's important?
・It makes traveling between China, Bali and Australia easier.
・Travelers from Guangzhou will be able to get to the island faster and cheaper.
・ Australian residents get a convenient connection to Bali on their way to China.
Flight details:
・Promo fares from $149 one-way.
・ Convenient connections for those flying from Guangzhou to Perth and back.
・ The connection to Bali will take 1.5 to 2.5 hours, depending on flight times.
Schedule:
Guangzhou - Perth (via Bali) - Monday, Tuesday, Thursday.
Perth to Guangzhou (via Bali) - Monday, Saturday.
@BaliNews
#tourism#airport#transport#destinations
✈️ New flights to Bali
Bali is steadily becoming a more sought-after destination for travelers from all over the world every year. To meet the growing demand, airlines are launching new flights to the island.
🇹🇭AirAsia: Bali to Phuket
AirAsia is launching a direct service between Bali and the popular resort of Phuket. Flights operate three times a week, on Tuesdays, Thursdays and Saturdays. Travel time is about four hours.
🇨🇳Hong Kong Airlines: Hong Kong to Bali
Hong Kong Airlines resumed flights to Bali after the pandemic, flying on Airbus A333s. Cathay Pacific was previously the only airline flying this route.
🇦🇪Emirates: Dubai to Bali
Emirates is doubling the number of flights to Bali using the Airbus A380. The flights will operate twice daily from September 1 to October 26.
🇷🇺Aeroflot: Moscow - Bali
Starting September 17, Aeroflot launches direct flights to Bali. The flight time is 12 hours. Tickets are already on sale.
✈️ Phuket – Bali
✈️ Hong Kong – Bali
✈️ Dubai – Bali
✈️ Moscow – Bali
@BaliNews
#wheretogo#airport#destinations#transport
✈️AirAsia launches new Bali to Darwinflight
📆 Popular low-cost carrier AirAsia is set to launch a new flight between Darwin (Australia) and Denpasar from March 22, 2025.
⏰ The flights will operate every Tuesday, Thursday and Saturday: Denpasar - Darwin 11:40 - 15:55, return 16:35 - 17:55.
@BaliNews
#transport#planes#destinations