Один из самых удобных способов записать данные это использование готовых форматов, такие как 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
🤔 Do you know how to use the phrase ‘bite the bullet’? Here’s an example sentence: “I decided to bite the bullet and start cleaning up after the party.” 🎉
💬 Can you write another example sentence?
EXTRA: to learn other useful expressions like this, click on our link in bio.
#LearnEnglish#Idioms#EnglishGrammar
🥗Salad? 🥕Carrots? 🍳Eggs? Do you like food as an adult that you hated when you were young? 🤮 Answer this grammar question – and then tell us all about it!
There's more about 'used' to on our website - just click the link in our bio! 👆👆👆
#Grammar#EnglishGrammar#LearnEnglish#English
📚First Conditional (Simple & Clear)
We use the first conditional to talk about real or possible situations in the present or future and their results.
🧩 Structure:
If + present simple, will + base verb
✅ If I pay attention in class, I will understand everything.
➡️ Real situation → real result.
#EnglishGrammar#Conditionals#LearnEnglish
👋 Learn how to use the present simple. Look at the images and complete the gap:
We _______ to school on Saturdays.
a. does not go
b. not go
c. don’t go
🤩 EXTRA: Click on our link in bio for more help with this tense.
#learnenglish#present#englishgrammar#englishtips
How to Learn a British Accent *Fast* - (Modern RP - ALL Vowels & Consonants!)
2023-03-23 by English with Lucy
#Grammar#EnglishGrammar#LearnEnglish
#YouTube#liked
Mastering Prepositions of Time: IN, ON, AT! ⏰
Do you ever get confused about which preposition to use when talking about time? You're not alone! Here is a quick cheat sheet to help you remember:
🎯 AT – for specific times (e.g., mealtimes, clock times, night, the weekend)
📅ON – for days and dates (e.g., Saturday, the 8th of September)
⏳IN – for longer periods (e.g., months, seasons, years, the morning)
Check out the infographic above for more examples!
Test your knowledge! Take the quick quiz below and see how much you've learned. Save this post for later, and forward it to a friend who is practicing their spoken English! 🔖
#LearnEnglish#EnglishGrammar#Prepositions#EnglishTips#ESL
🤯Oh no! We've all done it! But don't worry about your phone – can you answer this grammar question? We'll tell you the answer later! 😃
#pastsimple#englishgrammar#learnenglish#verbs#gapfill
There are lots of tag questions in English so which is the correct one? Look at the images and choose the correct tag question:
-
#learnenglish#questiontags#tagquestions#englishgrammar#englishtips#grammar
Difference Between “drop out” and “be dropped out”
Many people make this mistake:
❌ I was dropped out
This sentence is grammatically incorrect.
The correct structure is:
✅ I dropped out.
Meaning: I voluntarily left or withdrew from school/university.
Why “was dropped out” is wrong
“Drop out” is an intransitive verb.
It does not take an object, so it cannot be used in the passive voice.
❌ You cannot say:
I was dropped out of university.
Because dropping out is something you do yourself.
Correct Usage
If it was your decision:
I dropped out of university.
If it wasn’t your decision:
Use other verbs to express that:
I was expelled from university.
I was forced to leave university.
@fluencyinenglish
#EnglishGrammar#GrammarTips#DropOut#PassiveVoice#IntransitiveVerbs#IELTSGrammar#CommonMistakes#LearnEnglish#TEFL
Do you know how and when to use ‘in’, ‘on’ and ‘at’ to talk about time? ⏰
We normally use:
at – for specific times, such as mealtimes and clock times
on – with days and dates
in – for longer periods of time, such as months, seasons and years.
Save this post for later and don’t forget to share with a friend who loves learning English! 🔖
#LearnEnglish#EnglishGrammar#PrepositionsOfTime#InOnAt#GrammarTips#ESL#DailyEnglish
🛫 Advertising: @Advertise_on_Telegram