Python tool for converting files and office documents to Markdown.
optimize non-seekable stream buffering using shutil.copyfileobj (#1510)
Yasir Alibrahemf70e637af2f2
diff --git a/packages/markitdown/src/markitdown/_markitdown.py b/packages/markitdown/src/markitdown/_markitdown.pyindex 4f2fcbea..8e2fe6a3 100644--- a/packages/markitdown/src/markitdown/_markitdown.py+++ b/packages/markitdown/src/markitdown/_markitdown.py@@ -435,11 +435,7 @@ class MarkItDown:# Check if we have a seekable stream. If not, load the entire stream into memory.if not stream.seekable():buffer = io.BytesIO()- while True:- chunk = stream.read(4096)- if not chunk:- break- buffer.write(chunk)+ shutil.copyfileobj(stream, buffer)buffer.seek(0)stream = buffer