From: "trans (Thomas Sawyer)" Date: 2012-11-26T03:44:23+09:00 Subject: [ruby-core:50086] [ruby-trunk - Feature #7429] Provide options for core collections to customize behavior Issue #7429 has been updated by trans (Thomas Sawyer). That is interesting. I suspect part of the problem is the design of the Hash class itself --something I addressed before in #6442. If Hash had a core set of non-reducible methods which all the others depended, then those should be the only methods that would need to be targeted. Also, #prepend might be handy here, rather than "inserts itself into the method lookup process". Speed isn't everything. I think good design is at least, if not more, important. ---------------------------------------- Feature #7429: Provide options for core collections to customize behavior https://bugs.ruby-lang.org/issues/7429#change-33867 Author: headius (Charles Nutter) Status: Rejected Priority: Normal Assignee: Category: Target version: 2.0.0 Many folks know that Matz is a fan of having a few classes that handle a wide range of behavior. For this reason, I think we're unlikely to get a set of parallelism-safe collections added to Ruby. I propose an alternative that would allow parallel-executing implementations to offer concurrency-friendly versions without impact to any code. I would like to see a way to pass in an options hash to the .new construction of at least Hash and Array. For example: # Create a hash that is concurrenct-safe, resizes when density is > 3 keys per bucket, # and sets initial bucket count to 60 hsh = Hash.new(concurrent: true, density: 3, size: 60) Similar for Array: ary = Array.new(concurrent: true, size: 100) Options like density and size map directly to current implementation details of Hash and Array that are sometimes not accessible (you can't change the load factor for Hash, for example). Options like concurrent could be noops on MRI but would allow other implementations to provide safe versions of the collections behind the scenes. I know it may be too late for 2.0.0, but we implementers of parallel-executing Rubies feel the pain of thread-unsafe core structures every day. I think the ability to get thread-safe collections in Ruby core would go a long way toward dispelling the myth that Ruby is bad for concurrent application programming. -- http://bugs.ruby-lang.org/