Browse Source

[python] implement writeBytes in NativeBytesOutput (which is used for sys.io.File.write)

so we don't write one byte at a time like geniuses
Dan Korostelev 6 years ago
parent
commit
01bab8830b
1 changed files with 4 additions and 0 deletions
  1. 4 0
      std/python/io/NativeBytesOutput.hx

+ 4 - 0
std/python/io/NativeBytesOutput.hx

@@ -47,4 +47,8 @@ class NativeBytesOutput extends NativeOutput<RawIOBase>{
 	{
 	{
 		stream.write(new Bytearray([c]));
 		stream.write(new Bytearray([c]));
 	}
 	}
+
+	override function writeBytes( s : haxe.io.Bytes, pos : Int, len : Int ) : Int {
+		return stream.write(python.Syntax.code("{0}[{1}:{2}]", s.getData(), pos, pos + len));
+	}
 }
 }