0

using python 2.7 I have a couple of mbs of json data, that I need in two different files. Is it faster to just save that data into two files, using json.dump() Or is it better to save into 1 file, and then copy that file with a new name?

Which is considered as a "python" way? Thank you

Konstantin
  • 93
  • 1
  • 8
  • 1
    Two duplicate files? I would use [shutil](https://stackoverflow.com/a/123212/298607) personally but I don't think you would be judged for just saving the file twice either... – dawg Jul 12 '18 at 16:59
  • If either one is faster, copying is probably faster. But (a) it probably doesn’t matter, and (b) if you find out that it _is_ a bottleneck for your code, you should try both and test, rather than guessing, or asking others to guess. – abarnert Jul 12 '18 at 17:38
  • But meanwhile, if there really is a performance issue anywhere near this, are you sure you want a separate file as opposed to, say, a symlink? – abarnert Jul 12 '18 at 17:39
  • @abarnert it is a continuous process on a crappy VM on a crappy server, it's not gonna be a bottleneck, but may or may not be something that could save resources for other tasks. – Konstantin Jul 12 '18 at 22:35

0 Answers0