Skip to content

Commit

Permalink
Completely remove Array and Object proxies, they were a mistake and r…
Browse files Browse the repository at this point in the history
…esulted in misuses. Closes #82, #109.
  • Loading branch information
TkTech committed Sep 3, 2023
1 parent 10e2d7d commit 092ce41
Show file tree
Hide file tree
Showing 13 changed files with 24,602 additions and 22,024 deletions.
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
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
11 changes: 3 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,6 @@
# Shuts up *all* linters complaining about our unused imports.
_ALL_IMPORTS = [
Parser,
Array,
Object,
MAXSIZE_BYTES,
PADDING
]
Expand All @@ -34,8 +31,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 +44,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
69 changes: 5 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,32 +43,28 @@ 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:
...

Expand Down
Loading

0 comments on commit 092ce41

Please sign in to comment.