I would like to know which one of json.dump() or json.dumps() are the most efficient when it comes to encoding a large array to json format.
json.dump()
json.dumps()
You can simply replace
f.write(json.dumps(mytab,default=dthandler,indent=4))
by
json.dump(mytab, f, default=dthandler, indent=4)
This should "stream" the data into the file.