Closed jabbalaci closed 12 years ago
The name of the db is irrelevant at this point. Today it's json tomorrow may be tomorrows fancy format. I agree that it is a bit misleading because of the existence of the pickle module.
I've applied changes that put everything in a class: https://github.com/medecau/pickledb/commit/694cbbcf5c33364773faafbbb2357d41fd5aaa41
I agree with the point about too many I/O ops, I have some ideas about fixing this: Timed updates, forced updates(like @jabbalaci suggested) and or update inside __del__()
Regarding comments to the functions take a look at: https://github.com/medecau/pickledb/commit/feefa83a70b64ef7181cda1cd2d813004bdfc0f8
medecau's fork is really good and basically does everything this suggestion says. The last commit added the "dump" function is really good.
Hi,
I would have some ideas for improvements.
First, it should be called jsondb. You use json instead of pickle, so the name is very misleading. The line "import json as pickle" is terrible.
I would put everything in a class. Then you could have an interface like this:
Global variables are discouraged to use, but if you group everything in a class, you could use those variables in the class with 'self', like self.db, etc.
Also, you do lots of I/O operations. It should be kept in memory and the user could call dump himself: jdb.dump() , and then you write everything to a file.
Add comments to every function. At the end of the source, add this:
Laszlo