Один из самых удобных способов записать данные это использование готовых форматов, такие как 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
🇬🇧Popular English Idioms to Sound Like a Native Speaker
💣 BLEW ME AWAY:
✍🏽when something blows you away, you’re extremely impressed by it
🔺The exhibition just blew me away. I’d never seen so many beautiful paintings before.
☁️ BLOW SMOKE:
✍🏽to exaggerate or say things that aren’t true to make you seem better/ more knowledgeable than in reality
🔺I’m not blowing smoke. I have honestly read War and Peace by Tolstoy.
🐺 CRY WOLF:
✍🏽to call for help when you don’t need it
🔺Do you think Peter is in trouble or is he just crying wolf?
#sirjimmy
#teamjimmy
Show your true colours | show your true colors🎨
⌨Meaning
You show your true colours if you show what you're really like, or you reveal your true character.
🚦For example
👀Bob always acts like he's a strong, brave guy, but when the hurricane hit he showed his true colors. He was too scared to go check on old Mrs Flowers, our next-door neighbour.
👀The players showed their true colours when they came back from three goals down to win the match.
#sirjimmy
#teamjimmy
🇬🇧Popular English Idioms to Sound Like a Native Speaker
💣 BLEW ME AWAY:
✍🏽when something blows you away, you’re extremely impressed by it
🔺The exhibition just blew me away. I’d never seen so many beautiful paintings before.
☁️ BLOW SMOKE:
✍🏽to exaggerate or say things that aren’t true to make you seem better/ more knowledgeable than in reality
🔺I’m not blowing smoke. I have honestly read War and Peace by Tolstoy.
🐺 CRY WOLF:
✍🏽to call for help when you don’t need it
🔺Do you think Peter is in trouble or is he just crying wolf?
#sirjimmy
#teamjimmy
Show your true colours | show your true colors🎨
⌨Meaning
You show your true colours if you show what you're really like, or you reveal your true character.
🚦For example
👀Bob always acts like he's a strong, brave guy, but when the hurricane hit he showed his true colors. He was too scared to go check on old Mrs Flowers, our next-door neighbour.
👀The players showed their true colours when they came back from three goals down to win the match.
#sirjimmy
#teamjimmy
🌪️Negative Personality Idioms + Challenge 🎯
• 🗣️ A windbag – talks nonstop
• 🧊 A wet blanket – ruins the vibe
• 👀 A busybody / nosy parker – always in your business
• 👍 A yes-person – agrees with everything
• 😖 A pain in the neck – seriously annoying
• 🤯 A scatterbrain – forgetful and unfocused
• 👦 A mama’s boy – overly dependent
• 👐 A pushover – too easy to control
• 😈 A troublemaker – causes drama
• 💼 A social climber – status obsessed
• 🐢 A slowcoach – painfully slow
• 🗣️💬 A gossip – spreads rumors
• 🪨 A rolling stone – never settles
• 🛋️ A lazybones – super lazy
• 🎩 A stuffed shirt – too formal
• 😴 A bore – boring person
• 🧐 A snob – looks down on others
• 🚪 A gatecrasher – uninvited guest
• 🧠❌Narrow-minded – closed-off thinker
• 💔Hard-hearted –cold and cruel
• 🐖Pig-headed – stubborn AF
• 🐇Hare-brained – reckless thinker
💥Challenge:
Can you guess the idiom from the description? 🤔
1️⃣ Someone who ruins the fun at a party → ?
2️⃣ Someone who talks way too much → ?
3️⃣ Someone who is too easy to control → ?
💡 Tip: Try using one of these idioms in a sentence today! ✍️
#Idioms
#TeamJimmy
#SirJimmy
Stop and smell the roses 🌺
Meaning:
To relax; to take time out of one's busy schedule to enjoy or appreciate the beauty of life.
Example: 🌹
Slow down. Stop and smell the roses now and then.
#teamjimmy
#sirjimmy
#idioms
❌ A fast shower 🚿
✅ A quick shower
❌ Respond the door 🚪
✅ Answer the door
❌ Strong rain 🌧
✅ Heavy rain
❌ Celebrate a party 🎉
✅ Throw a party
❌ Ask for a wish 🤞🏻
✅ Make a wish
❌ Strong taste 😑
✅ Big taste
❌ Lost the time ⏳
✅ Waste time
❌ Nice dreams 🛌
✅ Sweet dreams
#sirjimmy
#teamjimmy
#idioms
🤨English Idioms Describing Character And Personality😜
✅1. Pain in the neck – an irritating, annoying person
Ex. Sarah is such a pain in the neck these days.
✅2. A people person – an outgoing person who gets along with people really well and is a good listener
Ex. Tom is enthusiastic and positive and he is a people person.
✅3. Party animal – someone who likes to attend parties often
Ex. Are you going out again tonight? You are such a party animal.
✅4. Cheapskate – a mean person who doesn’t like spending money
Ex. He was always a cheapskate even though he was earning $200,000 a year.
✅5. Happy camper – a person who is always happy and satisfied. We often use ‘happy camper’ in the negative.
Ex. The apartment was much smaller than I expected, I was not a happy camper.
✅6. Nerd – someone who is very interested in science or technology, particularly in computers
Ex. He spends all weekends at his laptop, he is such a nerd.
✅7. Life and soul of the party – someone who is energetic, and good fun during social occasions.
Ex. It was a great night, Jim was life and soul of the party.
✅8. Dipstick – a person who seems to be stupid (very informal)
Ex. I don’t know whether to laugh or be angry at his behaviour. What a complete dipstick!
✅9. Down-to-earth – someone who is practical and close to reality, who accepts other people as equals
Ex. Despite his wealth, he was a down-to-earth man. He was very generous and had a kind heart.
✅10. Early bird – a person who wakes up, arrives to work, etc. before the usual time
This expression comes from the English proverb “The early bird catches the worm”.
Ex. My Mum is the early bird in our family, she gets up at 5 o’clock in the morning.
✅11. Larger than life – someone who is more exciting or interesting than other people
Ex. All who knew him would agree that his personality was larger than life, he was a joy to be around.
#Idioms
#Teamjimmy
#sirjimmy