Skip to content

Commit 092ce41

Browse files
committed
Completely remove Array and Object proxies, they were a mistake and resulted in misuses. Closes #82, #109.
1 parent 10e2d7d commit 092ce41

13 files changed

Lines changed: 24602 additions & 22024 deletions

.bumpversion.cfg

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[bumpversion]
2-
current_version = 5.0.2
2+
current_version = 6.0.0
33
commit = True
44
tag = True
55

setup.py

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,15 +30,19 @@
3030
)
3131

3232
if os.getenv('BUILD_WITH_CYTHON') and CYTHON_AVAILABLE:
33-
macros = []
33+
macros = [
34+
('NDEBUG', 1)
35+
]
3436
compiler_directives = {
35-
'embedsignature': True
37+
'embedsignature': True,
38+
'boundscheck': False
3639
}
3740

3841
if os.getenv('BUILD_FOR_DEBUG'):
3942
# Enable line tracing, which also enables support for coverage
4043
# reporting.
4144
macros = [
45+
('CYTHON_PROFILE', 1),
4246
('CYTHON_TRACE', 1),
4347
('CYTHON_TRACE_NOGIL', 1)
4448
]
@@ -68,14 +72,17 @@
6872
'simdjson/csimdjson.cpp'
6973
],
7074
extra_compile_args=extra_compile_args,
71-
language='c++'
75+
language='c++',
76+
define_macros=[
77+
('NDEBUG', 1)
78+
]
7279
)
7380
]
7481

7582
setup(
7683
name='pysimdjson',
7784
packages=find_packages(),
78-
version='5.0.2',
85+
version='6.0.0',
7986
description='simdjson bindings for python',
8087
long_description=long_description,
8188
long_description_content_type='text/markdown',

simdjson/__init__.py

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,7 @@
55
from csimdjson import (
66
# Objects
77
Parser,
8-
Array,
9-
Object,
8+
Document,
109
# Constants
1110
MAXSIZE_BYTES,
1211
PADDING
@@ -17,8 +16,6 @@
1716
# Shuts up *all* linters complaining about our unused imports.
1817
_ALL_IMPORTS = [
1918
Parser,
20-
Array,
21-
Object,
2219
MAXSIZE_BYTES,
2320
PADDING
2421
]
@@ -34,8 +31,7 @@ def load(fp, *, cls=None, object_hook=None, parse_float=None, parse_int=None,
3431
- object_pairs_hook is ignored.
3532
- cls is ignored.
3633
"""
37-
parser = Parser()
38-
return parser.parse(fp.read(), True)
34+
return Parser().parse(fp.read()).as_object
3935

4036

4137
def loads(s, *, cls=None, object_hook=None, parse_float=None, parse_int=None,
@@ -48,8 +44,7 @@ def loads(s, *, cls=None, object_hook=None, parse_float=None, parse_int=None,
4844
- object_pairs_hook is ignored.
4945
- cls is ignored.
5046
"""
51-
parser = Parser()
52-
return parser.parse(s, True)
47+
return Parser().parse(s).as_object
5348

5449

5550
dumps = json.dumps

simdjson/__init__.pyi

Lines changed: 5 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,14 @@
11
import json
22
from pathlib import Path
33
from typing import (
4-
AbstractSet,
54
Any,
65
Dict,
76
Final,
8-
Iterator,
97
List,
10-
Mapping,
118
Optional,
129
Sequence,
1310
Tuple,
1411
Union,
15-
ValuesView,
1612
overload,
1713
)
1814

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

2420
Primitives = Union[int, float, str, bool]
25-
SimValue = Optional[Union['Object', 'Array', Primitives]]
21+
SimValue = Optional[Primitives]
2622
UnboxedValue = Optional[Union[Primitives, Dict[str, Any], List[Any]]]
2723

2824

29-
class Object(Mapping[str, SimValue]):
30-
def __getitem__(self, key: str) -> SimValue:
31-
...
32-
33-
def __iter__(self) -> Iterator[str]:
34-
...
35-
36-
def __len__(self) -> int:
37-
...
38-
39-
def as_dict(self) -> Dict[str, UnboxedValue]:
40-
...
41-
42-
def at_pointer(self, key: str) -> SimValue:
43-
...
44-
45-
def keys(self) -> AbstractSet[str]:
46-
...
47-
48-
def values(self) -> ValuesView[SimValue]:
49-
...
50-
51-
def items(self) -> AbstractSet[Tuple[str, SimValue]]:
52-
...
53-
54-
@property
55-
def mini(self) -> str:
56-
...
57-
58-
59-
class Array(Sequence[SimValue]):
60-
def __len__(self) -> int:
61-
...
62-
63-
def __getitem__(self, idx: Union[int, slice]) -> 'Array':
64-
...
65-
66-
def as_list(self) -> List[Optional[Union[Primitives, dict, list]]]:
67-
...
68-
69-
def as_buffer(self, *, of_type: Literal['d', 'i', 'u']) -> bytes:
70-
...
71-
72-
def at_pointer(self, key: str) -> SimValue:
73-
...
74-
75-
@property
76-
def mini(self) -> str:
77-
...
78-
79-
8025
class Parser:
8126
def __init__(self, max_capacity: int = ...) -> None:
8227
...
@@ -98,32 +43,28 @@ class Parser:
9843
@overload
9944
def load(
10045
self,
101-
path: Union[str, Path],
102-
recursive: Literal[False] = ...,
46+
path: Union[str, Path]
10347
) -> SimValue:
10448
...
10549

10650
@overload
10751
def load(
10852
self,
109-
path: Union[str, Path],
110-
recursive: Literal[True],
53+
path: Union[str, Path]
11154
) -> UnboxedValue:
11255
...
11356

11457
@overload
11558
def parse(
11659
self,
117-
data: Union[str, bytes, bytearray, memoryview],
118-
recursive: Literal[False] = ...,
60+
data: Union[str, bytes, bytearray, memoryview]
11961
) -> SimValue:
12062
...
12163

12264
@overload
12365
def parse(
12466
self,
125-
data: Union[str, bytes, bytearray, memoryview],
126-
recursive: Literal[True],
67+
data: Union[str, bytes, bytearray, memoryview]
12768
) -> UnboxedValue:
12869
...
12970

0 commit comments

Comments
 (0)