From b38291e078edde8b5f7982fb38a68e00a0472141 Mon Sep 17 00:00:00 2001 From: TermiNexus Date: Wed, 7 Oct 2026 08:48:21 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=203=20=E4=B8=AA?= =?UTF-8?q?=E7=A4=BA=E4=BE=8B=E5=B7=A5=E7=A8=8B=E7=BC=96=E8=AF=91=E5=A4=B1?= =?UTF-8?q?=E8=B4=A5=EF=BC=88gzip=20=E6=97=A7=20API=20/=20vipermath=20?= =?UTF-8?q?=E6=A8=A1=E5=9D=97=E5=90=8D=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 1) ViperMNIST/App/lib/MnistData.vp:inflate_local 改用真实的 GzipFile OOP API(ok/err/read_all()/dst_len/close())——原调用的 gzip_decode_bytes / gzip_ok / gzip_read / gzip_dst_len / gzip_close 在 includes/gzip.vp 中均不存在。 2) ViperSpeedBenchmark/App/main.vp:import vipermath 改为 import math as vipermath——仓库内无 vipermath 模块,且该文件只用到 math.fmod。 --- ViperMNIST/App/lib/MnistData.vp | 21 ++++++++++++--------- ViperSpeedBenchmark/App/main.vp | 2 +- 2 files changed, 13 insertions(+), 10 deletions(-) diff --git a/ViperMNIST/App/lib/MnistData.vp b/ViperMNIST/App/lib/MnistData.vp index db1cebb..533e0db 100644 --- a/ViperMNIST/App/lib/MnistData.vp +++ b/ViperMNIST/App/lib/MnistData.vp @@ -168,7 +168,7 @@ def download_inflate(url: str, out_path: str) -> int: if dst is None: requests.release(r) return 1 - n = gzip.gzip_decode_bytes(src, slen, dst, cap) + n = gzip._gzip_decode(src, slen, dst, cap) if n == -9 or n == -18 or n == -23: stdlib.free(dst) dst = None @@ -199,23 +199,26 @@ def inflate_local(gz_path: str, out_path: str) -> int: """本地已下载的 .gz → 解压写入 out_path(GzipFile OOP 范式)。0=成功""" stdio.printf("[gzip] 本地解压: %s\n", gz_path) gz: gzip.GzipFile* = gzip.GzipFile(gz_path) - if gz is None or gzip.gzip_ok(gz) == 0: - stdio.printf("[gzip] 打开失败(err=%d): %s\n", gzip.gzip_err(gz), gz_path) + if gz is None: + stdio.printf("[gzip] 打开失败: %s\n", gz_path) return 1 - buf: BYTEPTR = gzip.gzip_read(gz) - n: sizet = gzip.gzip_dst_len(gz) + if gz.ok == 0: + stdio.printf("[gzip] 打开失败(err=%d): %s\n", gz.err, gz_path) + return 1 + buf: BYTEPTR = gz.read_all() + n: sizet = gz.dst_len if buf is None or n == 0: - stdio.printf("[gzip] 解压失败(err=%d): %s\n", gzip.gzip_err(gz), gz_path) - gzip.gzip_close(gz) + stdio.printf("[gzip] 解压失败(err=%d): %s\n", gz.err, gz_path) + gz.close() return 1 f: fileio.File* = fileio.File(out_path, fileio.MODE.W) if f.closed: stdio.printf("[gzip] 无法写入: %s\n", out_path) - gzip.gzip_close(gz) + gz.close() return 1 f.write(buf, ULONG(n)) f.close() - gzip.gzip_close(gz) + gz.close() stdio.printf("[gzip] 已写入 %s (%zu 字节)\n", out_path, n) return 0 diff --git a/ViperSpeedBenchmark/App/main.vp b/ViperSpeedBenchmark/App/main.vp index 6f38a88..4f09bae 100644 --- a/ViperSpeedBenchmark/App/main.vp +++ b/ViperSpeedBenchmark/App/main.vp @@ -43,7 +43,7 @@ # ============================================================ from stdint import * import vipersimd -import vipermath +import math as vipermath import stdlib import stdio import t