Code Monkey home page Code Monkey logo

Comments (3)

darvid avatar darvid commented on June 12, 2024

Can you try 9823622? This is a backwards incompatible change that will require all handlers to return something truthy, otherwise Hyperscan will halt stream scanning. So return False to halt, True to continue, for example. I think the negated return value allows for more Pythonic code, especially since Hyperscan doesn't care (for now) what the exact return value from Python is.

from python-hyperscan.

sixers avatar sixers commented on June 12, 2024

Hey, thank you for such a timely response!

However, I'm not sure if reversing the logic from the original hyperscan library is a good idea. It might lead to non-obvious bugs, especially when someone forgets to add a return in their function:

def my_handler(*args, **kwargs):
    print(*args)

If I understand correctly, this will halt after the first match, which might be suprising to the users. Because this package lacks documentation, people will refer to the original hyperscan docs, which won't help them in that case.

WDYT?

from python-hyperscan.

darvid avatar darvid commented on June 12, 2024

Good point, I think that makes more sense for now. It weirds me out because True and success in Python don't generally map to 0, and the C API expects 1 (failure state) from the match handler to actually halt scanning. So if you somehow had to return a bool in the C API, you would return False to stop scanning.

But I think you're right about ease of use. The reverse logic (return None to continue scanning, True or anything truthy to halt) is implemented in #7, along with a substantial packaging update and some initial documentation.

Let me know if there's anything else otherwise I will close the ticket. Thanks for your feedback!

from python-hyperscan.

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.