Issue #17311 has been reported by S_H_ (Shun Hiraoka). ---------------------------------------- Feature #17311: Improve performance Array#deconstruct & Array#to_ary https://bugs.ruby-lang.org/issues/17311 * Author: S_H_ (Shun Hiraoka) * Status: Open * Priority: Normal ---------------------------------------- Improve performance `Array#deconstruct` & `Array#to_ary` with Ruby code. like this. ```ruby class Array def deconstruct return self end def to_ary return self end end ``` benchmark: ```yml prelude: | sary = Array.new(10) mary = Array.new(1000) lary = Array.new(30_000_000) benchmark: - sary.deconstruct - mary.deconstruct - lary.deconstruct - sary.to_ary - mary.to_ary - lary.to_ary loop_count: 20000000 ``` benchmark result: ```bash sh@MyComputer:~/rubydev/build$ make benchmark/benchmark.yml -e COMPARE_RUBY=~/.rbenv/shims/ruby -e BENCH_RUBY=../install/bin/ruby # Iteration per second (i/s) | |compare-ruby|built-ruby| |:-----------------|-----------:|---------:| |sary.deconstruct | 72.866M| 74.310M| | | -| 1.02x| |mary.deconstruct | 73.665M| 80.049M| | | -| 1.09x| |lary.deconstruct | 74.924M| 86.865M| | | -| 1.16x| |sary.to_ary | 70.203M| 81.387M| | | -| 1.16x| |mary.to_ary | 72.142M| 78.847M| | | -| 1.09x| |lary.to_ary | 70.473M| 86.382M| | | -| 1.23x| ``` COMPARE_RUBY is `ruby 3.0.0dev (2020-11-07T13:12:22Z master 5823f6c25b) [x86_64-linux]`. BENCH_RUBY is ahead of `ruby 3.0.0dev (2020-11-07T13:12:22Z master 5823f6c25b) [x86_64-linux]`. Also expect to improve the performance of pattern matching using arrays. -- 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>