Issue #16987 has been reported by zverok (Victor Shepelev). ---------------------------------------- Feature #16987: Enumerator::Lazy vs Array methods https://bugs.ruby-lang.org/issues/16987 * Author: zverok (Victor Shepelev) * Status: Open * Priority: Normal ---------------------------------------- Context: Early in Ruby's life, it was made a design decisions for our enumerations to be greedy (immediately executed on method chaining). Sometimes it is not practical (e.g. 2mln strings array -- drop comments, split into fields, find first 10 whose field 2 is equal search value), so one either resorts to non-idiomatic "do everything in one `each` block", or to `Enumerable#lazy`. There are three problems with latter: 1. It is much less known 2. It is said to be _almost always_ slow than non-lazy, and therefore not recommended 3. It lacks some methods that are often necessary in processing large data chunks. I want to discuss (3) here. Examples of methods `Enumerator::Lazy` would better, but actually don't have: `#flatten`, `#product`, `#compact`. One might notice it all methods of the Array, not Enumerable, but 1. probably they _should_ be present in `Enumerable` (none of them require anything besides `#each` to function) 2. they are definitely useful to lazily process large sequences. -- https://bugs.ruby-lang.org/ Unsubscribe: <mailto:ruby-core-request / ruby-lang.org?subject=unsubscribe> <http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-core>