|
|
|
|
|
by poizan42
815 days ago
|
|
> Though now I will break your mind as my mind was broken not a long time ago. Powershell, which is often said to be a better shell, works like that. It doesn't run things in parallel. I think the same is to be said about Windows cmd/batch, but don't cite me on that. That one thing makes Powershell insufficient to ever be a full replacement of a proper shell. 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) class InfiniteEnumerator : System.Collections.IEnumerator
{
hidden [ulong]$countMod2e64 = 0
[object] get_Current()
{
return $this.countMod2e64
}
[bool] MoveNext() {
$this.countMod2e64 += 1
return $true
}
Reset() {
$this.countMod2e64 = 0
}
}
class InfiniteEnumerable : System.Collections.IEnumerable {
InfiniteEnumerable() {}
[System.Collections.IEnumerator] GetEnumerator() {
return [InfiniteEnumerator]::new()
}
}
[InfiniteEnumerable]::new() | ForEach-Object { Write-Host "Element number mod 2^64: $_" }
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. |
|