Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

v7.0.0 #110

Open
wants to merge 10 commits into
base: master
Choose a base branch
from
2 changes: 1 addition & 1 deletion .bumpversion.cfg
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[bumpversion]
current_version = 5.0.2
current_version = 6.0.0
commit = True
tag = True

Expand Down
21 changes: 10 additions & 11 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
on:
workflow_dispatch:
push:
tags:
- 'v*' # Push events to matching v*, i.e. v1.0, v20.15.10
release:
types:
- published

name: Creating release

Expand All @@ -19,10 +18,10 @@ jobs:
name: Creating source release
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3

- name: Setting up Python
uses: actions/setup-python@v2
uses: actions/setup-python@v4
with:
python-version: 3.8

Expand Down Expand Up @@ -54,12 +53,12 @@ jobs:
os: [ubuntu-20.04, windows-2019, macos-10.15]
# cp - CPython
# pp - PyPy
py: ["cp36", "cp37", "cp38", "cp39", "cp310", "pp37", "pp38", "pp39"]
py: ["cp38", "cp39", "cp310", "cp311", "pp37", "pp38", "pp39"]

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3

- uses: actions/setup-python@v2
- uses: actions/setup-python@v4
name: Setting up Python
with:
python-version: '3.8'
Expand Down Expand Up @@ -100,10 +99,10 @@ jobs:
needs: [upload_all]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3

- name: Setting up Python
uses: actions/setup-python@v2
uses: actions/setup-python@v4
with:
python-version: 3.8

Expand Down
24 changes: 14 additions & 10 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -1,24 +1,28 @@
name: Run tests

on: [push, pull_request, workflow_dispatch]
on:
push:
branches:
- master
pull_request:

jobs:
# Tests that are platform-agnostic.
universal:
runs-on: ubuntu-latest
steps:
- name: Set up Python 3.9
uses: actions/setup-python@v2
uses: actions/setup-python@v4
with:
python-version: 3.9
python-version: 3.11

- uses: actions/checkout@v2
- uses: actions/checkout@v3

- name: Installing platform dependencies
run: >
sudo apt-get install -y
build-essential
clang-6.0
clang-15

- name: Installing python dependencies
env:
Expand Down Expand Up @@ -46,27 +50,27 @@ jobs:
build:
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
fail-fast: true
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
python-version: [3.6, 3.7, 3.8, 3.9, "3.10"]
python-version: [3.8, 3.9, "3.10", "3.11"]

steps:
# Python needs to be setup before checkout to prevent files from being
# left in the source tree. See setup-python/issues/106.
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}

- uses: actions/checkout@v2
- uses: actions/checkout@v3

- name: Installing platform dependencies
if: matrix.os == 'ubuntu-latest'
run: >
sudo apt-get install -y
build-essential
clang-6.0
clang-15

- name: Installing python dependencies
env:
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ If SIMD instructions are unavailable a fallback parser is used, making
pysimdjson safe to use anywhere.

Bindings are currently tested on OS X, Linux, and Windows for Python version
3.6 to 3.9.
3.8 to 3.11.

## 📝 Documentation

Expand Down
8 changes: 3 additions & 5 deletions docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ If SIMD instructions are unavailable a fallback parser is used, making
pysimdjson safe to use anywhere.

Bindings are currently tested on OS X, Linux, and Windows for Python version
3.6 to 3.10.
3.8 to 3.11.

Installation
------------
Expand All @@ -44,16 +44,14 @@ Binary wheels are available for the following:
+--------------+-------+-------+-------+---------+---------+
| Interpreter | OS X | Win | Linux | Linux | Linux |
+==============+=======+=======+=======+=========+=========+
| CPython 3.6 | Yes | Yes | Yes | Yes | Yes |
+--------------+-------+-------+-------+---------+---------+
| CPython 3.7 | Yes | Yes | Yes | Yes | Yes |
+--------------+-------+-------+-------+---------+---------+
| CPython 3.8 | Yes | Yes | Yes | Yes | Yes |
+--------------+-------+-------+-------+---------+---------+
| CPython 3.9 | Yes | Yes | Yes | Yes | Yes |
+--------------+-------+-------+-------+---------+---------+
| CPython 3.10 | Yes | Yes | Yes | Yes | Yes |
+--------------+-------+-------+-------+---------+---------+
| CPython 3.11 | Yes | Yes | Yes | Yes | Yes |
+--------------+-------+-------+-------+---------+---------+

When binary wheels are not available, a C++11 (or better) compiler is required
when installing in order to build the underlying simdjson library.
Expand Down
15 changes: 11 additions & 4 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,15 +30,19 @@
)

if os.getenv('BUILD_WITH_CYTHON') and CYTHON_AVAILABLE:
macros = []
macros = [
('NDEBUG', 1)
]
compiler_directives = {
'embedsignature': True
'embedsignature': True,
'boundscheck': False
}

if os.getenv('BUILD_FOR_DEBUG'):
# Enable line tracing, which also enables support for coverage
# reporting.
macros = [
('CYTHON_PROFILE', 1),
('CYTHON_TRACE', 1),
('CYTHON_TRACE_NOGIL', 1)
]
Expand Down Expand Up @@ -68,14 +72,17 @@
'simdjson/csimdjson.cpp'
],
extra_compile_args=extra_compile_args,
language='c++'
language='c++',
define_macros=[
('NDEBUG', 1)
]
)
]

setup(
name='pysimdjson',
packages=find_packages(),
version='5.0.2',
version='6.0.0',
description='simdjson bindings for python',
long_description=long_description,
long_description_content_type='text/markdown',
Expand Down
12 changes: 4 additions & 8 deletions simdjson/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@
from csimdjson import (
# Objects
Parser,
Array,
Object,
Document,
# Constants
MAXSIZE_BYTES,
PADDING
Expand All @@ -17,8 +16,7 @@
# Shuts up *all* linters complaining about our unused imports.
_ALL_IMPORTS = [
Parser,
Array,
Object,
Document,
MAXSIZE_BYTES,
PADDING
]
Expand All @@ -34,8 +32,7 @@ def load(fp, *, cls=None, object_hook=None, parse_float=None, parse_int=None,
- object_pairs_hook is ignored.
- cls is ignored.
"""
parser = Parser()
return parser.parse(fp.read(), True)
return Parser().parse(fp.read()).as_object


def loads(s, *, cls=None, object_hook=None, parse_float=None, parse_int=None,
Expand All @@ -48,8 +45,7 @@ def loads(s, *, cls=None, object_hook=None, parse_float=None, parse_int=None,
- object_pairs_hook is ignored.
- cls is ignored.
"""
parser = Parser()
return parser.parse(s, True)
return Parser().parse(s).as_object


dumps = json.dumps
Expand Down
78 changes: 14 additions & 64 deletions simdjson/__init__.pyi
Original file line number Diff line number Diff line change
@@ -1,18 +1,14 @@
import json
from pathlib import Path
from typing import (
AbstractSet,
Any,
Dict,
Final,
Iterator,
List,
Mapping,
Optional,
Sequence,
Tuple,
Union,
ValuesView,
overload,
)

Expand All @@ -22,61 +18,10 @@ except ImportError:
from typing_extensions import Literal # type: ignore

Primitives = Union[int, float, str, bool]
SimValue = Optional[Union['Object', 'Array', Primitives]]
SimValue = Optional[Primitives]
UnboxedValue = Optional[Union[Primitives, Dict[str, Any], List[Any]]]


class Object(Mapping[str, SimValue]):
def __getitem__(self, key: str) -> SimValue:
...

def __iter__(self) -> Iterator[str]:
...

def __len__(self) -> int:
...

def as_dict(self) -> Dict[str, UnboxedValue]:
...

def at_pointer(self, key: str) -> SimValue:
...

def keys(self) -> AbstractSet[str]:
...

def values(self) -> ValuesView[SimValue]:
...

def items(self) -> AbstractSet[Tuple[str, SimValue]]:
...

@property
def mini(self) -> str:
...


class Array(Sequence[SimValue]):
def __len__(self) -> int:
...

def __getitem__(self, idx: Union[int, slice]) -> 'Array':
...

def as_list(self) -> List[Optional[Union[Primitives, dict, list]]]:
...

def as_buffer(self, *, of_type: Literal['d', 'i', 'u']) -> bytes:
...

def at_pointer(self, key: str) -> SimValue:
...

@property
def mini(self) -> str:
...


class Parser:
def __init__(self, max_capacity: int = ...) -> None:
...
Expand All @@ -98,39 +43,44 @@ class Parser:
@overload
def load(
self,
path: Union[str, Path],
recursive: Literal[False] = ...,
path: Union[str, Path]
) -> SimValue:
...

@overload
def load(
self,
path: Union[str, Path],
recursive: Literal[True],
path: Union[str, Path]
) -> UnboxedValue:
...

@overload
def parse(
self,
data: Union[str, bytes, bytearray, memoryview],
recursive: Literal[False] = ...,
data: Union[str, bytes, bytearray, memoryview]
) -> SimValue:
...

@overload
def parse(
self,
data: Union[str, bytes, bytearray, memoryview],
recursive: Literal[True],
data: Union[str, bytes, bytearray, memoryview]
) -> UnboxedValue:
...


dumps = json.dumps
dump = json.dump


def loads(s, *, cls=None, object_hook=None, parse_float=None,
parse_int=None, parse_constant=None, object_pairs_hook=None, **kw): ...


def load(fp, *, cls=None, object_hook=None, parse_float=None, parse_int=None,
parse_constant=None, object_pairs_hook=None, **kwargs): ...


MAXSIZE_BYTES: Final[int] = ...
PADDING: Final[int] = ...
VERSION: Final[str] = ...
Loading