Skip to content
Discussion options

You must be logged in to vote

senko compares each file by loading all of it into RAM, and that's what breaks on v1.29. urequests.get(url).text holds the response bytes, then a decoded str copy, then the local file for the comparison. Each of those needs its own contiguous block of heap, so an 8 KB main.py needs roughly three 8 KB blocks at once.

Streaming the file in 512-byte chunks and comparing SHA-1 hashes keeps peak use to one small buffer, whatever the file size:

import requests, hashlib, os

BUF = bytearray(512)
MV = memoryview(BUF)

def file_sha1(path):
    h = hashlib.sha1()
    try:
        with open(path, "rb") as f:
            while n := f.readinto(BUF):
                h.update(MV[:n])
    except OSError:…

Replies: 5 comments 8 replies

Comment options

Josverl
Sep 21, 2026
Collaborator Sponsor

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
2 replies
@Josverl
Comment options

Josverl Sep 23, 2026
Collaborator Sponsor

@dave0003
Comment options

Comment options

You must be logged in to vote
3 replies
@dave0003
Comment options

@Josverl
Comment options

Josverl Sep 23, 2026
Collaborator Sponsor

@shariltumin
Comment options

Comment options

You must be logged in to vote
1 reply
@dave0003
Comment options

Answer selected by dave0003
Comment options

You must be logged in to vote
2 replies
@projectgus
Comment options

@dave0003
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
5 participants