Comments (6)
Eh, Python is the land of generators. I totally expect Python programmers to get that jq is a generator.
Besides that, if a given jq program will be outputting lots of values, then using a generator will be more "online" than collecting them into an array and outputting the array.
from jq.py.
master now has a new API that supports producing an iterator for the output.
from jq.py.
Mainly that people tend to understand lists better than generators, and they're easier to deal with. If there's a compelling reason to use generators instead, then I'm open to suggestions.
from jq.py.
@mwilliamson I have to completely agree with @nicowilliams .
Python really shines in generators, iterators (very well done in Python 2.x, even more in Python 3.x), what allows to process huge streams of data with really small amount of memory needed just for processing part of the task (something on level of one record transformation).
I accept, that generators are not what beginners understand from very first lesson, but it is definitely a feature, which makes Python really strong tool and it is not so complex as it looks at the first moment.
As @nicowilliams has mentioned, in case someone would process large (or possibly indefinite) stream of json data, generators are the only way to go.
from jq.py.
I've been playing with exposing a generator in a separate branch (see the tests). One issue I've come across is that potentially many instances of jq_state
are required for the same program since many executions could be on-going at one time for the same program (since we no longer guarantee that the execution is completed in one go).
Is there a cheap way to copy a compiled program (i.e. copy jq_state
immediately after jq_compile
)? cc @nicowilliams
from jq.py.
@mwilliamson libjq should be reentrant, so multiple jq_state
instances should be no problem. We don't have a way to copy a jq_state
instance, but so what, that's just an optimization that we can add.
from jq.py.
Related Issues (20)
- how can I package this so that it can be reused as Lambda Layer in AWS? HOT 1
- 'OverflowError: cannot convert float infinity to integer' when handling big numbers HOT 3
- walk built-in function does not work HOT 1
- Output values truncated on "null bytes" HOT 2
- Is there a way to output query result without quotes (i.e. "jq -r ") HOT 1
- Error building wheel for jq during "pip install jq" HOT 1
- Cython-3 support HOT 3
- Tests failing with jq-1.7 HOT 1
- Useless `-lonig` when building using system libraries HOT 1
- Behaviour of Out Method first() on JSON Array Output HOT 1
- tox.ini missing in sdist - please add HOT 1
- Variable support
- Module support HOT 1
- Logging support
- ImportError on arm64 (Mac OSX M1) with jq 1.5.0 and 1.6.0 HOT 7
- install error HOT 1
- Specify jq command-line options HOT 2
- Add type hints as a `.pyi` stub file
- json.dumps: ensure_ascii
- Is it possible to input_file? HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from jq.py.