Commit 523f64b
Support serializing models larger than 2**31 - 1 (#624)
* Support serializing models larger than 2**31 - 1
Previously `treelite` used `ctypes.string_at` to copy the serialized
bytes return value to a new python `bytes` object. This method takes a
pointer and a length (expressed as an `int`). Python `bytes` objects
have a max capacity of `Py_ssize_t`, not `int`. This meant that
serializing very large models could error as the `size` parameter would
overflow an `int`.
We now use `PyBytes_FromStringAndSize` directly, avoiding this issue.
It's hard to write a sane test for this that can run on CI, but I've
verified that things are working locally.
* Fix tests
---------
Co-authored-by: Philip Hyunsu Cho <chohyu01@cs.washington.edu>
Co-authored-by: Hyunsu Cho <phcho@nvidia.com>1 parent b457e5d commit 523f64b
2 files changed
+15
-2
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
12 | 12 | | |
13 | 13 | | |
14 | 14 | | |
15 | | - | |
| 15 | + | |
16 | 16 | | |
17 | 17 | | |
18 | 18 | | |
| |||
345 | 345 | | |
346 | 346 | | |
347 | 347 | | |
348 | | - | |
| 348 | + | |
349 | 349 | | |
350 | 350 | | |
351 | 351 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
20 | 20 | | |
21 | 21 | | |
22 | 22 | | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
23 | 28 | | |
24 | 29 | | |
25 | 30 | | |
| |||
35 | 40 | | |
36 | 41 | | |
37 | 42 | | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
38 | 51 | | |
39 | 52 | | |
40 | 53 | | |
| |||
0 commit comments