Comments (2)
Added pypy
's 30 times runtime improvement to the README
from streamable.
Few rough runtime orders of magnitude
Base snippet:
# main.py
from streamable import Stream
print(
sum(
Stream(range(1, 1_000_000_000))
.map(lambda n: 1/n)
)
)
interpreted by CPython
% time python3 main.py
21.30048150134855
python3 main.py 102.75s user 0.09s system 99% cpu 1:43.61 total
interpreted by PyPy
% time pypy3 main.py
21.30048150134855
pypy3 main.py 2.12s user 0.02s system 99% cpu 2.162 total
Java stream
// Main.java
import java.util.stream.IntStream;
public class Main {
public static void main(String[] args) {
double sum = IntStream
.range(1, 1_000_000_000)
.mapToDouble(n -> 1.0 / n)
.sum();
System.out.println(sum);
}
}
% javac Main.java
% time java -XX:+UseG1GC Main
21.300481501347942
java -XX:+UseG1GC Main 4.15s user 0.03s system 99% cpu 4.200 total
C for loop
// main.c
#include <stdio.h>
int main() {
double sum = 0.0;
for (long long int i = 1; i < 1000000000; ++i) {
sum += 1.0 / i;
}
printf("%.15f\n", sum);
return 0;
}
% gcc -O3 -o main_optimized.out main.c
% time ./main_optimized.out
21.300481501348550
./main_optimized.out 1.02s user 0.00s system 99% cpu 1.034 total
Rust iterators
// main.rs
fn main() {
let sum: f64 = (1..1_000_000_000)
.map(|n| 1.0 / n as f64)
.sum();
println!("{}", sum);
}
% rustc -C opt-level=2 ./main.rs
% time ./main
21.30048150134855
./main 1.00s user 0.00s system 98% cpu 1.014 total
from streamable.
Related Issues (8)
- `.limit`: add a `predicate: Callable[[T], bool]` parameter to stop the iteration based on an arbitrary condition HOT 1
- `.group`: optimize when `by` is `None`
- README: create a complete yet short ETL Stream example
- `.throttle`: do not base the logic on a "min period" and add `seconds_interval`
- README: Add a section explaining the delegation of reading/writing from/to Parquet/CSV/JSON
- Make `Stream[T]` implement `AsyncIterable[T]` too
- I can't get it to print anything or logger.info anything HOT 1
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 streamable.