Re:Why does an extraneous build step make my Zig app 10x fas...
by MatejKafka on Wednesday March 20, 2024 @09:42AM
(#39766352)
More compact example (not to scare the POSIX people away :) ):
0..1000000 | where {$_ % 10 -eq 0} | foreach {"Got Value: $_"}
Re:Why does an extraneous build step make my Zig app 10x fas...
by poizan42 on Wednesday March 20, 2024 @10:00AM
(#39766643)
The streaming behavior of the range operator is weird though. This is tested on PowerShell 7.4.1
> 0..1000000000 | % { $_ }
# Starts printing out numbers immediately
> 0..1000000000
# Hangs longer than I had patience to wait for
> $x=0..100
> $x.GetType()
# IsPublic IsSerial Name BaseType
# -------- -------- ---- --------
# True True Object[] System.Array
It's an array when I save it in a variable, but it's obviously not an array on the LHS of a pipe.
A Pipeline is PowerShell is definitely streaming unless you accidentally forces the output into a list/array at some point, e.g. try this for yourself (somewhere you can interrupt the script obviously as it's going to run forever)
Whether it runs in parallel depends on the implementation of each side. Interpreted powershell code does not run in parallel unless you run it a job, use ForEach-Object -Parallel, or explicitly put it on another thread. But the data is not collected together before being sent from one step from the next.