[#67346] Future of test suites for Ruby — Charles Oliver Nutter <headius@...>

I'll try to be brief so we can discuss all this. tl;dr: RubySpec is

19 messages 2015/01/05

[ruby-core:67802] [ruby-trunk - Feature #10782] [Open] Patch: Add constants for BigDecimal for ZERO, ONE, TEN

From: garysweaver@...
Date: 2015-01-25 16:25:00 UTC
List: ruby-core #67802
Issue #10782 has been reported by Gary Weaver.

----------------------------------------
Feature #10782: Patch: Add constants for BigDecimal for ZERO, ONE, TEN
https://bugs.ruby-lang.org/issues/10782

* Author: Gary Weaver
* Status: Open
* Priority: Normal
* Assignee: 
----------------------------------------
We found with use of BigDecimal that we were often needing to compare BigDecimal with zero or initialize BigDecimal as 0 for a default value. This introduces a bit move overhead than is typically needed, since a simple BigDecimal.new('0') will suffice without any additional arguments. This BigDecimal instance does not change, so it makes sense to make it a constant.

In Java, they found that constants for zero, one, and ten were useful (see http://docs.oracle.com/javase/7/docs/api/java/math/BigDecimal.html#ZERO), so I thought it would be good to submit a patch for Ruby 2.3.0, just to see whether others would find this useful. I understand that we don't want to have constants for every possible value, and that it might be helpful if these had the same object id across ruby implementations similar to lower integer values having the same object id, however I don't think it is necessary or useful to compare object_id's for BigDecimal value comparison- the point is only not to have to retain and create new instances of BigDecimal for ZERO, ONE, or TEN.

---Files--------------------------------
ruby-changes.patch (2.67 KB)


-- 
https://bugs.ruby-lang.org/

In This Thread

Prev Next