#!/usr/bin/env python import _pyio as io import time COPY_SIZE = 5 * 1024**3 BUF_SIZE = 128 * 1024 ofh = open('/dev/null', 'wb') ifh_r = open('/dev/zero', 'rb', buffering=0) ifh = io.BufferedReader(ifh_r) buf = bytearray(BUF_SIZE) stamp = time.time() copied = 0 while copied < COPY_SIZE: len_ = ifh.readinto(buf) ofh.write(buf[:len_]) copied += len_ print('readinto: %.3e seconds' % (time.time() - stamp,)) if hasattr(ifh, 'readinto1'): stamp = time.time() copied = 0 while copied < COPY_SIZE: len_ = ifh.readinto1(buf) ofh.write(buf[:len_]) copied += len_ print('readinto1: %.3e seconds' % (time.time() - stamp,)) else: print('readinto1 not available')