Comments (3)
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.
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.
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)
- symbol not found in flat namespace '_ch_alloc_scratch' HOT 10
- Add args for early termination of scanning if only need to find one match regex or just judging matched
- document release/publish process
- Illegal instruction crash on import HOT 1
- loadb docs example requires a mode
- switch to vectorscan HOT 2
- Request for maintainer(s) HOT 5
- multiprocessing problem.
- Memory leak in Database object when compiling, dumping and loading. HOT 15
- Strange "hyperscan.InvalidError: error code -1" HOT 6
- Named capture groups with Chimera
- install by Dockerfile
- v0.2.0 does not work with Python 3.10 HOT 5
- ModuleNotFoundError: No module named 'hyperscan._hyperscan'
- when it will be ready for windows ? HOT 1
- Please do a release HOT 1
- Problem with musl and fat runtime? HOT 5
- pypi don't have py3.9 whl release and tar.gz with source code HOT 2
- Python 3.10 using error
- Can't import from hyperscan in python 3.12 HOT 7
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 python-hyperscan.