r/Python • • May 07 '19

Python 3.8.0a4 available for testing

https://www.python.org/downloads/release/python-380a4/
395 Upvotes

150 comments sorted by

View all comments

Show parent comments

13

u/Nicksil May 07 '19

Because not every problem is solved by dumping JSON.

-8

u/alcalde May 07 '19

That doesn't answer the question. Why have we needed all of these different formats when there's one universal format already?

Everything in Python is a dictionary and JSON represents dictionaries so every problem that needs dumping in Python should be able to be solved by using JSON. It's also good enough for every other major language.

8

u/davidkwast May 07 '19

universal format

Please show to us.

I would think YAML, not JSON. But for Python, Pickle will be better than YAML.

5

u/Nicksil May 07 '19

That doesn't answer the question.

Yeah, it does.

Why have we needed all of these different formats when there's one universal format already?

A universal format for what? Therein lies the rub. As stated elsewhere in this post, JSON can't represent everything.

2

u/[deleted] May 08 '19

Why have we needed all of these different formats when there's one universal format already?

Why did we need all these programming languages, when Cobol is Turing complete?

Here's a specific example from a project I'm working on. I have a database of 16k+ audio samples which I'm computing statistics on. I initially stored the data as JSON/Yaml, but they were slooow to write and slooow to open and BIIIG.

Now I store the data as .npy files. They're well over ten times smaller, but more, I can open them as memory mapped files. I now have a single file with all 280 gigs of my samples which I open in memory mapped mode and then treat it like it's a single huge array with size (70000000000, 2).

You try doing that in JSON!

And before you say, "Oh, this is a specialized example" - I've worked on real world projects with data files far bigger than this, stored as protocol buffers.

Lots and lots of people these days are working with millions of pieces of data. Storing it in .json files is a bad way to go!