We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
mmap could greatly improve the performance of .at(…, key=…).session()
The text was updated successfully, but these errors were encountered:
import time import mmap def naive_insert_at_beginning(): t1 = time.monotonic() with open("ddb_storage/users copy.json", "r+b") as f: data = f.read() f.seek(0) f.write(b"aaaa" + data) f.flush() t2 = time.monotonic() print(f"Time taken: {(t2 - t1) * 1000}ms") # naive_insert_at_beginning() def mmap_insert_at_beginning(): t1 = time.monotonic() append_str = b"dddd" with open("ddb_storage/users copy.json", "a+b") as f: f.seek(0, 2) f.write(append_str) f.flush() with mmap.mmap(f.fileno(), 0, flags=mmap.MAP_PRIVATE, ) as m: m.move(0, 4, len(m) - 4) m.seek(0) m.write(append_str) m.flush() t2 = time.monotonic() print(f"Time taken: {(t2 - t1) * 1000}ms") mmap_insert_at_beginning()
Sorry, something went wrong.
No branches or pull requests
mmap could greatly improve the performance of .at(…, key=…).session()
The text was updated successfully, but these errors were encountered: