Conversation
That's a good point. It's definitely something we should fix.
I thought about it and the only alternative I could come up with was using persistent data structures. That would require us to rely on an external library like pyrsistent and incur some performance penalty on it's own, but would allow us to avoid creating a 2nd copy of all data. What do you think about this? |
|
It'd be ideal to avoid external dependencies -- that's one of the goals of TinyDB, right? I just tweaked the patch to implement copy-on-write, so we're saved the deepcopy when the serializers don't apply. |
That were my concerns, too. If anyone runs into performance troubles because of the copying, one can fork this project and adapt it accordingly. I'll go with your PR. |
|
A new version of tinydb-serialization is now being uploaded to PyPI :) |
I noticed, while working on recipy, that calling
db.insert(data)on a dict with the DateTimeSerializer enabled will changedatain-place, replacing eachdatetimewith the serialized string. My fix is to do adeepcopyof the data dict as the first step ofwrite. Not the most efficient, but it does the trick.