Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

5x swifter CPython bindings and first NodeJS bindings #52

Merged
merged 86 commits into from
Oct 10, 2023
Merged

Conversation

ashvardanian
Copy link
Owner

@ashvardanian ashvardanian commented Oct 5, 2023

So why would anyone replace the easy-to-use PyBind11 with almost 2,000 lines of pure CPython bindings?! Of course, to lower the latency! PyBind11 wraps every C++ object with a smart pointer, puts a hash table next to it, and addresses function pointers with std::string key lookups 🤯

Let's see where it gets us if benchmarking with the "Leipzig1M" dataset. The bandwidth-oriented functions are just as fast as in the past:

  • Hashing the dataset: 77 ms vs 16 ms. 4.5x faster
  • Counting the number of "the": 151 ms vs 45 ms. 3.3x faster
  • Split all whitespace-delimited words: 782 ms vs 338 ms. 2.3x faster
  • Split around every "the": 240 ms vs 48 ms. 5x faster

What about the latency-oriented ones?

  • Find the first whitespace: 1ns vs 3ns 3x slower
  • Partition around the first whitespace: 73ms vs 33ns. 2212x faster

r2rSahakyan and others added 30 commits September 2, 2023 23:35
Span class with size , hash, comparison, contains and find functions.
all added code under #ifndef PURE_CPYTHON
@ashvardanian ashvardanian changed the title Pure CPython bindings and NodeJS bindings draft 5x swifter CPython bindings and first NodeJS bindings Oct 10, 2023
@ashvardanian ashvardanian merged commit e5ef92b into main Oct 10, 2023
5 checks passed
@ashvardanian
Copy link
Owner Author

🎉 This PR is included in version 2.0.0 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

vmanot pushed a commit to vmanot/StringZilla that referenced this pull request Jan 29, 2024
5x swifter CPython bindings and first NodeJS bindings
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants