cysimdjson icon indicating copy to clipboard operation
cysimdjson copied to clipboard

detailed documentation and examples

Open faker09 opened this issue 4 years ago • 8 comments

there is not any documentation to introduce any function and module. so it is difficult to use it for a person that have not experience

faker09 avatar Aug 05 '21 13:08 faker09

there is not cysimdjson.JSONParser().parse_string function

faker09 avatar Aug 06 '21 14:08 faker09

it look like that cysimdjson is not yet finished

faker09 avatar Aug 06 '21 14:08 faker09

The Readme.md says there is a parser.loads function but there is no such a thing:

>>> parser = cysimdjson.JSONParser()
>>> parser.loads
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
AttributeError: 'cysimdjson.JSONParser' object has no attribute 'loads'

seperman avatar Sep 28 '21 01:09 seperman

@seperman - you likely used some intermediate (master) version. The cysimdjson underwent an architecture refactoring at that time, sorry for inconvenience.

Current version behaviour:

>>> parser = cysimdjson.JSONParser()
>>> print(parser.loads)
<built-in method loads of cysimdjson.JSONParser object at 0x7ffe9fe25ab0>
>>> print(parser.parse_string)
<built-in method parse_string of cysimdjson.JSONParser object at 0x7ffe9fe25ab0>

ateska avatar Nov 06 '21 12:11 ateska

In general, for a newcomers I would recommend to stick with pysimdjson - it is more user-friendly and comparably fast in version 4.0

This project remains alive mainly b/c we are squeeze some performance from it in very specific case: using C API in the code that lives outside of the Python (C code) and still needs an access to parsed JSON structures. If that's possible with pysimdjson, this one could be closed since it served its original purpose.

ateska avatar Nov 06 '21 12:11 ateska

If that's possible with pysimdjson, this one could be closed since it served its original purpose.

I'm happy to support this use case if you can describe the API you need exposed on the C side of things.

TkTech avatar Dec 06 '21 01:12 TkTech

If that's possible with pysimdjson, this one could be closed since it served its original purpose.

I'm happy to support this use case if you can describe the API you need exposed on the C side of things.

The generic idea is that the "other code" (meaning non-Python, maybe Cython, maybe LLVM IR, maybe other compiled/binary code) would like to access the parsed JSON, using simdjson directly using the element that has been parsed by cysimdjson.

This is an API: https://github.com/TeskaLabs/cysimdjson/blob/main/cysimdjson/cysimdjsonc.h - it is basically a simplistic wrapper of C++ code in the opaque C memory block + set of bridging functions that allows to call specific method of simdjson.

ateska avatar Dec 06 '21 09:12 ateska

I've taken a look at it and I see no issue supporting it, although I might change how you acquire it to be a bit different, passing around a PyCapsule so that it can be passed around safely in C or via Python to other C functions without void typing and with support for garbage collection. I'll look at adding it towards the end of December when the office is on holidays.

TkTech avatar Dec 09 '21 03:12 TkTech