-
Notifications
You must be signed in to change notification settings - Fork 19
Add Cython .pxd declarations and Python type stubs #56
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
Open
wiese-m
wants to merge
3
commits into
TeskaLabs:main
Choose a base branch
from
wiese-m:main
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,157 @@ | ||
| # cython: language_level=3 | ||
|
|
||
| from libc.stdint cimport int64_t, uint64_t | ||
| from libcpp cimport bool | ||
| from libcpp.string cimport string | ||
|
|
||
|
|
||
| cdef extern from "<string_view>" namespace "std": | ||
| cppclass string_view: | ||
| pass | ||
|
|
||
|
|
||
| cdef extern from "pysimdjson/errors.h": | ||
| cdef void simdjson_error_handler() | ||
|
|
||
|
|
||
| cdef extern from "simdjson/simdjson.h" namespace "simdjson": | ||
|
|
||
| cdef size_t SIMDJSON_MAXSIZE_BYTES | ||
| cdef size_t SIMDJSON_PADDING | ||
|
|
||
| cdef enum: | ||
| SIMDJSON_VERSION_MAJOR | ||
| SIMDJSON_VERSION_MINOR | ||
| SIMDJSON_VERSION_REVISION | ||
|
|
||
|
|
||
| cdef extern from "simdjson/simdjson.h" namespace "simdjson::dom": | ||
|
|
||
| cdef cppclass key_value_pair "simdjson::dom::key_value_pair": | ||
| string_view key | ||
| simdjson_element value | ||
|
|
||
| cdef cppclass simdjson_object "simdjson::dom::object": | ||
|
|
||
| cppclass iterator: | ||
| iterator() | ||
|
|
||
| key_value_pair operator*() | ||
| iterator& operator++() | ||
| bint operator==(iterator) | ||
| bint operator!=(iterator) | ||
|
|
||
| string_view key() | ||
| simdjson_element value() | ||
|
|
||
| simdjson_object() | ||
|
|
||
| iterator begin() | ||
| iterator end() | ||
|
|
||
| size_t size() | ||
|
|
||
| simdjson_element at_pointer(const char*) except +simdjson_error_handler | ||
| simdjson_element operator[](const char*) except +simdjson_error_handler | ||
|
|
||
|
|
||
| cdef cppclass simdjson_array "simdjson::dom::array": | ||
|
|
||
| cppclass iterator: | ||
| iterator() | ||
|
|
||
| iterator& operator++() | ||
| bint operator!=(iterator) | ||
| simdjson_element operator*() | ||
|
|
||
| simdjson_array() | ||
|
|
||
| iterator begin() | ||
| iterator end() | ||
|
|
||
| size_t size() | ||
|
|
||
| simdjson_element at(int) except +simdjson_error_handler | ||
| simdjson_element at_pointer(const char*) except +simdjson_error_handler | ||
|
|
||
|
|
||
| cdef cppclass simdjson_element "simdjson::dom::element": | ||
|
|
||
| simdjson_element() | ||
|
|
||
| simdjson_element_type type() except +simdjson_error_handler | ||
|
|
||
| bool get_bool() except +simdjson_error_handler | ||
| int64_t get_int64() except +simdjson_error_handler | ||
| uint64_t get_uint64() except +simdjson_error_handler | ||
| double get_double() except +simdjson_error_handler | ||
| simdjson_array get_array() except +simdjson_error_handler | ||
| simdjson_object get_object() except +simdjson_error_handler | ||
|
|
||
| simdjson_element at_pointer(const char*) except +simdjson_error_handler | ||
|
|
||
|
|
||
| cdef cppclass simdjson_parser "simdjson::dom::parser": | ||
|
|
||
| simdjson_parser() | ||
| simdjson_parser(size_t max_capacity) | ||
|
|
||
| simdjson_element load(string) except +simdjson_error_handler nogil | ||
| simdjson_element parse(const char * buf, size_t len, bool realloc_if_needed) except +simdjson_error_handler nogil | ||
|
|
||
|
|
||
| cdef extern from "simdjson/simdjson.h" namespace "simdjson::dom::element_type": | ||
| cdef enum simdjson_element_type "simdjson::dom::element_type": | ||
| OBJECT, | ||
| ARRAY, | ||
| STRING, | ||
| INT64, | ||
| UINT64, | ||
| DOUBLE, | ||
| BOOL, | ||
| NULL_VALUE | ||
|
|
||
|
|
||
| cdef class JSONObject: | ||
|
|
||
| cdef: | ||
| simdjson_element Element | ||
| simdjson_object Object | ||
|
|
||
| cpdef object at_pointer(self, key) | ||
| cpdef object get_value(self) | ||
| cpdef object export(self) | ||
|
|
||
|
|
||
| cdef class JSONArray: | ||
|
|
||
| cdef: | ||
| simdjson_element Element | ||
| simdjson_array Array | ||
|
|
||
| cpdef object at_pointer(self, key) | ||
| cpdef object get_value(self) | ||
| cpdef object export(self) | ||
|
|
||
|
|
||
| cdef class JSONElement: | ||
|
|
||
| cdef: | ||
| simdjson_element Element | ||
|
|
||
| @staticmethod | ||
| cdef from_element(simdjson_element element) | ||
|
|
||
| cpdef object at_pointer(self, key) | ||
| cpdef object get_value(self) | ||
| cpdef object export(self) | ||
|
|
||
|
|
||
| cdef class JSONParser: | ||
|
|
||
| cdef: | ||
| simdjson_parser Parser | ||
|
|
||
| cpdef object parse(self, bytes event) | ||
| cpdef object parse_in_place(self, bytes event) | ||
| cpdef object parse_string(self, str event) | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,45 @@ | ||
| from typing import Any, Iterator | ||
|
|
||
| class JSONObject: | ||
| def __contains__(self, key: str) -> bool: ... | ||
| def __iter__(self) -> Iterator[str]: ... | ||
| def __getitem__(self, key: str) -> Any: ... | ||
| def __len__(self) -> int: ... | ||
| def items(self) -> Iterator[tuple[str, Any]]: ... | ||
| def get(self, key: str, default: Any = None) -> Any: ... | ||
| def keys(self) -> Iterator[str]: ... | ||
| def at_pointer(self, key: str) -> Any: ... | ||
| def get_value(self) -> "JSONObject": ... | ||
| def export(self) -> dict: ... | ||
| def get_addr(self) -> int: ... | ||
|
|
||
| class JSONArray: | ||
| def __contains__(self, item: Any) -> bool: ... | ||
| def __getitem__(self, key: int) -> Any: ... | ||
| def __len__(self) -> int: ... | ||
| def __iter__(self) -> Iterator[Any]: ... | ||
| def at_pointer(self, key: str) -> Any: ... | ||
| def get_value(self) -> "JSONArray": ... | ||
| def export(self) -> list: ... | ||
| def get_addr(self) -> int: ... | ||
|
|
||
| class JSONElement: | ||
| def at_pointer(self, key: str) -> "JSONElement": ... | ||
| def get_value(self) -> Any: ... | ||
| def export(self) -> Any: ... | ||
| def get_addr(self) -> int: ... | ||
|
|
||
| class JSONParser: | ||
| def __init__(self, max_capacity: int | None = None) -> None: ... | ||
| def parse(self, event: bytes) -> JSONObject | JSONArray | JSONElement: ... | ||
| def parse_in_place(self, event: bytes) -> JSONObject | JSONArray | JSONElement: ... | ||
| def parse_string(self, event: str) -> JSONObject | JSONArray | JSONElement: ... | ||
| def load(self, path: str) -> Any: ... | ||
| def loads(self, content: str) -> Any: ... | ||
| def active_implementation(self) -> str: ... | ||
|
|
||
| def addr_to_element(element_addr: int) -> JSONObject | JSONArray | JSONElement: ... | ||
|
|
||
| MAXSIZE_BYTES: int | ||
| PADDING: int | ||
| SIMDJSON_VERSION: str |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.