Skip to content

Instantly share code, notes, and snippets.

View serhiy-storchaka's full-sized avatar

Serhiy Storchaka serhiy-storchaka

View GitHub Profile
@serhiy-storchaka
serhiy-storchaka / copyfile-mmap.py
Last active January 29, 2020 13:18
Copy files using mmap
import sys, mmap
with open(sys.argv[1], 'rb') as src:
with open(sys.argv[2], 'wb') as dst:
mm = mmap.mmap(src.fileno(), 0, access=mmap.ACCESS_READ)
dst.write(mm)
@serhiy-storchaka
serhiy-storchaka / copyfile-sendfile.py
Created January 29, 2020 11:28
Copy files using sendfile
import sys, os
with open(sys.argv[1], 'rb') as src:
with open(sys.argv[2], 'wb') as dst:
size = os.stat(src.fileno()).st_size
os.sendfile(dst.fileno(), src.fileno(), 0, size)
diff --git a/index.rst b/index.rst
index f1ae6a9..f682fd6 100644
--- a/index.rst
+++ b/index.rst
@@ -48,8 +48,7 @@ Compact encoding::
Pretty printing::
>>> import simplejson as json
- >>> s = json.dumps({'4': 5, '6': 7}, sort_keys=True, indent=4 * ' ')
- >>> print('\n'.join([l.rstrip() for l in s.splitlines()]))