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

fast number parsing #965

Closed
gabyx opened this issue Feb 8, 2018 · 10 comments
Closed

fast number parsing #965

gabyx opened this issue Feb 8, 2018 · 10 comments

Comments

@gabyx
Copy link

gabyx commented Feb 8, 2018

I once optimized a string conversion from string2double/float and integral type:
It turned out to beat anything I've seen so far (except probably some geeky-assembler optimized code):

Here the GIST:
https://gist.github.com/gabyx/cd8ea9e727f5683a1fc654020edb6951

taken from here:
https://github.com/gabyx/GRSFramework/blob/5f1e8dca647d45d2f3b85e4a440b0f1195470b45/common/include/GRSF/common/FastStringConversion.hpp#L28

maybe it is of any help here, if it is faster ;-). It could serve as a drop-in replacement. This is tested, and was used years ago. It should be safe =)

@OvermindDL1
Copy link

That code is GPL3'd.

@nlohmann
Copy link
Owner

nlohmann commented Feb 9, 2018

Thanks a lot. This seems to be very close to the strtod implementation, see https://opensource.apple.com/source/tcl/tcl-10/tcl/compat/strtod.c for example. We used such code in the past, but shifted to a hand-written version for more flexibility and support for our use cases. Furthermore, GPL3 is not acceptable as this is an MIT licensed project.

@nlohmann nlohmann closed this as completed Feb 9, 2018
@gabyx
Copy link
Author

gabyx commented Feb 9, 2018

Ah nice :-), Ehm ->
You have the permission to use it for your project as MIT licence, if you wanna use it (if it is faster, what ever? :-). Is that enough? Or do I personally need to make it MIT :-)?

@OvermindDL1
Copy link

Or do I personally need to make it MIT :-)?

If you even really looked at GPL3 code and based the code on it's design, then your code basically needs to be GPL3 as well, it is an extremely viral license.

Also, as a side note, I've not seen any faster than the one in the Boost.Spirit2/3 library. ^.^

@gabyx
Copy link
Author

gabyx commented Feb 9, 2018

But as an author: I can change the licence at any time I want to another one, or is this prohibited?
I know that GPL3 is extermely viral and I only like this concept in research code. I like the MPL2 approach more :-). Probably Boost.Spirit is even faster yes, I have once done some benchmarks compared to the std::library which was awefully slow back then (4 years ago) :-).... I just thought about posting it here, since you need number parsing :-).

@OvermindDL1
Copy link

But as an author: I can change the licence at any time I want to another one, or is this prohibited?

If your code is 'based on' GPL3 code, even if you typed every character yourself, it, sadly, is still GPL3...

The C++ standard library conversions are so slow because of so much memory work they do. The C functions are so slow compared to Boost.Spirit because they have to handle locale and other such annoyances. Boost.Spirit on the other hand makes specialized templates for the precise code of what you precisely want to parse in whatever base you want, which is why it is so fast. If any library is determined to be faster the Boost.Spirit dev's fix up theirs to either match or beat it. The nice things of template metaprogramming. :-)

Plus with Boost.Spirit you could parse all of a JSON document super-fast into about any container you want. There is a simple/readable JSON parser made in Boost.Spirit on github somewhere, though it just parses into whatever you want, it doesn't have a nice and easy access thing in all ways like this library does.

@nlohmann
Copy link
Owner

nlohmann commented Feb 9, 2018

We will not add a Boost dependency to this library. If there is a drop-in replacement for our current conversion with an MIT-compatible license and that is measured to be faster, I am happy to have a look.

@OvermindDL1
Copy link

We will not add a Boost dependency to this library. If there is a drop-in replacement for our current conversion with an MIT-compatible license and that is measured to be faster, I am happy to have a look.

Oh I never suggested doing so! Boost.Spirit can be used standalone without boost as well, but even then it follows the boost license so you can easily pick parts out of it, like number parsing, as necessary, no GPL issues. :-)

@gabyx
Copy link
Author

gabyx commented Feb 13, 2018 via email

@OvermindDL1
Copy link

Interesting conversation: that basically means. I can make the whole project another license because of this invasively gpl just in order to use a snippet out of it. how stupid :). thanks for the clarification :).

Yeah that's the GPL for you. The second I see anything as GPL (or a few minor others) I immediately write it off and pretend it does not exist... ^.^;

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants