Code Monkey home page Code Monkey logo

Comments (6)

nicowilliams avatar nicowilliams commented on July 29, 2024 1

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.

mwilliamson avatar mwilliamson commented on July 29, 2024 1

master now has a new API that supports producing an iterator for the output.

from jq.py.

mwilliamson avatar mwilliamson commented on July 29, 2024

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.

vlcinsky avatar vlcinsky commented on July 29, 2024

@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.

mwilliamson avatar mwilliamson commented on July 29, 2024

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.

nicowilliams avatar nicowilliams commented on July 29, 2024

@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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.