Skip to content

Commit

Permalink
Build 3.13 alpha 3 compatibility, misc
Browse files Browse the repository at this point in the history
  • Loading branch information
ijl committed Feb 3, 2024
1 parent 6d7e1ac commit 55bb0c6
Show file tree
Hide file tree
Showing 8 changed files with 66 additions and 29 deletions.
15 changes: 12 additions & 3 deletions .github/workflows/debug.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,12 @@ jobs:
profile: [
{ rust: "1.65", features: "" },
{ rust: "1.65", features: "--features=yyjson" },
{ rust: "nightly-2024-01-17", features: "--features=yyjson,unstable-simd" },
{ rust: "nightly-2024-02-01", features: "--features=yyjson,unstable-simd" },
]
python: [
{ version: '3.12', abi: 'cp312-cp312' },
{ version: '3.8', abi: 'cp38-cp38' },
{ version: '3.13' },
{ version: '3.12' },
{ version: '3.8' },
]
env:
CC: "gcc"
Expand All @@ -26,7 +27,9 @@ jobs:

- uses: actions/setup-python@v5
with:
allow-prereleases: true
python-version: '${{ matrix.python.version }}'

- run: python -m pip install --user --upgrade pip "maturin>=1,<2" wheel

- uses: actions/checkout@v4
Expand All @@ -43,9 +46,15 @@ jobs:
- run: python -m pip install --user -r test/requirements.txt -r integration/requirements.txt

- run: pytest -s -rxX -v test
timeout-minutes: 4
env:
PYTHONMALLOC: "debug"

- run: ./integration/run thread
timeout-minutes: 2

- run: ./integration/run http
timeout-minutes: 2

- run: ./integration/run init
timeout-minutes: 2
8 changes: 4 additions & 4 deletions .github/workflows/linux.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,8 @@ jobs:
options: --user 0
steps:
- run: yum install -y clang lld
- run: curl https://sh.rustup.rs -sSf | sh -s -- --default-toolchain nightly-2024-01-17 --profile minimal -y
- run: rustup component add rust-src --toolchain nightly-2024-01-17-x86_64-unknown-linux-gnu
- run: curl https://sh.rustup.rs -sSf | sh -s -- --default-toolchain nightly-2024-02-01 --profile minimal -y
- run: rustup component add rust-src --toolchain nightly-2024-02-01-x86_64-unknown-linux-gnu
- uses: actions/checkout@v4

- name: build-std
Expand Down Expand Up @@ -143,7 +143,7 @@ jobs:
RUSTFLAGS: "-C target-feature=-crt-static"
CARGO_UNSTABLE_SPARSE_REGISTRY: "true"
with:
rust-toolchain: nightly-2024-01-17
rust-toolchain: nightly-2024-02-01
rustup-components: rust-src
target: ${{ matrix.platform.target }}
manylinux: musllinux_1_1
Expand Down Expand Up @@ -238,7 +238,7 @@ jobs:
RUSTFLAGS: "${{ matrix.target.rustflags }}"
with:
target: ${{ matrix.target.target }}
rust-toolchain: nightly-2024-01-17
rust-toolchain: nightly-2024-02-01
rustup-components: rust-src
manylinux: auto
args: --release --strip --out=dist --features=${{ matrix.target.features }} -i python${{ matrix.python.version }}
Expand Down
32 changes: 16 additions & 16 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,13 @@ keywords = ["fast", "json", "dataclass", "dataclasses", "datetime", "rfc", "8259
include = [
"Cargo.toml",
"CHANGELOG.md",
"data/*",
"data",
"include",
"LICENSE-APACHE",
"LICENSE-MIT",
"pyproject.toml",
"README.md",
"src/*",
"src",
"test/*.py",
"test/requirements.txt",
]
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -1196,7 +1196,7 @@ It benefits from also having a C build environment to compile a faster
deserialization backend. See this project's `manylinux_2_28` builds for an
example using clang and LTO.

The project's own CI tests against `nightly-2024-01-17` and stable 1.65. It
The project's own CI tests against `nightly-2024-02-01` and stable 1.65. It
is prudent to pin the nightly version because that channel can introduce
breaking changes.

Expand Down
2 changes: 1 addition & 1 deletion ci/azure-pipelines.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
variables:
toolchain: nightly-2024-01-17
toolchain: nightly-2024-02-01

jobs:

Expand Down
8 changes: 8 additions & 0 deletions src/util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -238,12 +238,20 @@ macro_rules! use_immortal {
};
}

#[cfg(not(Py_3_13))]
macro_rules! pydict_next {
($obj1:expr, $obj2:expr, $obj3:expr, $obj4:expr) => {
unsafe { pyo3_ffi::_PyDict_Next($obj1, $obj2, $obj3, $obj4, std::ptr::null_mut()) }
};
}

#[cfg(Py_3_13)]
macro_rules! pydict_next {
($obj1:expr, $obj2:expr, $obj3:expr, $obj4:expr) => {
unsafe { pyo3_ffi::PyDict_Next($obj1, $obj2, $obj3, $obj4) }
};
}

macro_rules! reserve_minimum {
($writer:expr) => {
$writer.reserve(64);
Expand Down
24 changes: 22 additions & 2 deletions test/test_type.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,10 @@ def test_str_long(self):
for obj in ("aaaa" * 1024, "üýþÿ" * 1024, "好" * 1024, "�" * 1024):
assert orjson.loads(orjson.dumps(obj)) == obj

def test_str_2mib(self):
ref = '🐈🐈🐈🐈🐈"üýa0s9999🐈🐈🐈🐈🐈9\0999\\9999' * 1024 * 50
assert orjson.loads(orjson.dumps(ref)) == ref

def test_str_very_long(self):
"""
str long enough to trigger overflow in bytecount
Expand Down Expand Up @@ -524,14 +528,30 @@ def test_dict(self):
def test_dict_duplicate_loads(self):
assert orjson.loads(b'{"1":true,"1":false}') == {"1": False}

def test_dict_large(self):
def test_dict_large_dict(self):
"""
dict with >512 keys
"""
obj = {"key_%s" % idx: "value" for idx in range(513)}
obj = {"key_%s" % idx: [{}, {"a": [{}, {}, {}]}, {}] for idx in range(513)}
assert len(obj) == 513
assert orjson.loads(orjson.dumps(obj)) == obj

def test_dict_large_4096(self):
"""
dict with >4096 keys
"""
obj = {"key_%s" % idx: "value_%s" % idx for idx in range(4097)}
assert len(obj) == 4097
assert orjson.loads(orjson.dumps(obj)) == obj

def test_dict_large_65536(self):
"""
dict with >65536 keys
"""
obj = {"key_%s" % idx: "value_%s" % idx for idx in range(65537)}
assert len(obj) == 65537
assert orjson.loads(orjson.dumps(obj)) == obj

def test_dict_large_keys(self):
"""
dict with keys too large to cache
Expand Down

0 comments on commit 55bb0c6

Please sign in to comment.