Converting ascii text into (floating-point) numeric values is a verycommon problem. Thefast_floatheader-only C++ library byDanielLemire does this very well, and very fast at up to or over to 1gigabyte per second as described in more detail in arecent arXiv paper.
This package brings this header-only library to R so that other Ruser can access it simply by addingLinkingTo: RcppFastFloat.
A modified example function is included, try
library(RcppFastFloat)exampleParse()with default arguments—or supply some arguments. We also include asimple timing comparison in the filebenchmark/comparison.R which youcan run just call viaRscript orr. Onour machine,fast_float comes out as just over 3 times asfast as the next best alternative (and this counts the function callsand all, so pure parsing speed is still a little bettter).
>source("comparison.R")Unit: milliseconds expr min lq mean median uq max neval cld scanf218.8936224.1223238.5650227.1901229.91161343.433100 c atof124.8087127.3274129.4104128.5858130.9138146.334100 b strtod124.5705127.2157129.1238129.1042130.7504137.143100 b stod127.1751129.7343131.7339131.4854133.1425147.763100 b fastfloat40.621941.304242.572942.320943.173857.788100 a>Or in chart form:

Right now the package is brand new and reasonably empty.
Any problems, bug reports, or features requests for the package canbe submitted and handled most conveniently asGithubissues in the repository.
Before submitting pull requests, it is frequently preferable to firstdiscuss need and scope in such an issue ticket. See the fileContributing.md(in theRcpp repo) for abrief discussion.
For the R package,DirkEddelbuettel andBrendanKnapp.
For everything pertaining tofast_float,Daniel Lemire (andcontributors).
Initially created: Fri Feb 5 05:27:23 PM CST 2021
Last modified: Sun May 26 10:12:05 CDT 2024