[#106341] [Ruby master Bug#18369] users.detect(:name, "Dorian") as shorthand for users.detect { |user| user.name == "Dorian" } — dorianmariefr <noreply@...>
Issue #18369 has been reported by dorianmariefr (Dorian Mari辿).
14 messages
2021/11/30
[#106351] [Ruby master Bug#18371] Release branches (release information in general) — "tenderlovemaking (Aaron Patterson)" <noreply@...>
Issue #18371 has been reported by tenderlovemaking (Aaron Patterson).
7 messages
2021/11/30
[ruby-core:106286] [Ruby master Feature#5378] Prime.each is slow
From:
"hsbt (Hiroshi SHIBATA)" <noreply@...>
Date:
2021-11-26 06:31:38 UTC
List:
ruby-core #106286
Issue #5378 has been updated by hsbt (Hiroshi SHIBATA).
Status changed from Assigned to Closed
prime.rb was extracted to https://github.com/ruby/prime as the bundled gems.
If you still have the motivation of this proposal, can you file this to the new canonical repository? Thanks.
----------------------------------------
Feature #5378: Prime.each is slow
https://bugs.ruby-lang.org/issues/5378#change-94911
* Author: mconigliaro (Mike Conigliaro)
* Status: Closed
* Priority: Normal
* Assignee: yugui (Yuki Sonoda)
----------------------------------------
See discussion here: https://gist.github.com/1246868
require 'benchmark'
require 'prime'
def primes_up_to(n)
s = [nil, nil] + (2..n).to_a
(2..(n ** 0.5).to_i).reject { |i| s[i].nil? }.each do |i|
(i ** 2).step(n, i) { |j| s[j] = nil }
end
s.compact
end
Benchmark.bm(12) do |x|
x.report('primes_up_to') { primes_up_to(2000000).inject(0) { |memo,obj| memo + obj } }
x.report('Prime.each') { Prime.each(2000000).inject(0) { |memo,obj| memo + obj } }
end
$ ruby -v
ruby 1.9.2p290 (2011-07-09 revision 32553) [x86_64-darwin10.8.0]
$ ruby lol.rb
user system total real
primes_up_to 1.470000 0.020000 1.490000 ( 1.491340)
Prime.each 7.820000 0.010000 7.830000 ( 7.820969)
---Files--------------------------------
prime.patch (4.06 KB)
--
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>