NEWS for Ruby 2.7.0

This document is a list of user visible feature changes made between releases except for bug fixes.

Note that each entry is kept so brief that no reason behind or reference information is supplied with. For a full list of changes with all sufficient information, see the ChangeLog file or Redmine (e.g. https://bugs.ruby-lang.org/issues/$FEATURE_OR_BUG_NUMBER)

Changes since the 2.6.0 release

Language changes

Core classes updates (outstanding ones only)

Complex
New method
  • Added Complex#<=>. So 0 <=> 0i will not raise NoMethodError. [Bug #15857]

Dir
Modified method
  • Dir#glob and Dir#[] no longer allow NUL-separated glob pattern. Use Array instead. [Feature #14643]

Encoding
  • Added new encoding CESU-8 [Feature #15931]

Enumerable
New methods
Enumerator
New method
  • Added Enumerator::Lazy#eager that generates a non-lazy enumerator from a lazy enumerator. [Feature #15901]

  • Added Enumerator::Yielder#to_proc so that a Yielder object can be directly passed to another method as a block argument. [Feature #15618]

Fiber
New method
FrozenError
New method
GC
New method
  • Added GC.compact method for compacting the heap. This function compacts live objects in the heap so that fewer pages may be used, and the heap may be more CoW friendly. [Feature #15626]

    Details on the algorithm and caveats can be found here: bugs.ruby-lang.org/issues/15626

IO
New method
Integer
Modified method
  • Integer#[] now supports range operation. [Feature #8842]

    0b01001101[2, 4]  #=> 0b0011
    0b01001100[2..5]  #=> 0b0011
    0b01001100[2...6] #=> 0b0011
        ^^^^
Module
New method
Modified method
ObjectSpace::WeakMap
Modified method
Regexp / String
  • Update Unicode version and Emoji version from 11.0.0 to 12.0.0. [Feature #15321]

  • Update Unicode version to 12.1.0, adding support for U+32FF SQUARE ERA NAME REIWA. [Feature #15195]

RubyVM
Removed method
  • RubyVM.resolve_feature_path moved to $LOAD_PATH.resolve_feature_path. [Feature #15903] [Feature #15230]

Time
New methods
Modified method
UnboundMethod
New methods

`umethod.bind_call(obj, …)` is semantically equivalent to `umethod.bind(obj).call(…)`. This idiom is used in some libraries to call a method that is overridden. The added method does the same without allocation of intermediate Method object.

class Foo
  def add_1(x)
    x + 1
  end
end
class Bar < Foo
  def add_1(x) # override
    x + 2
  end
end

obj = Bar.new
p obj.add_1(1) #=> 3
p Foo.instance_method(:add_1).bind(obj).call(1) #=> 2
p Foo.instance_method(:add_1).bind_call(obj, 1) #=> 2
$LOAD_PATH
New method
  • Added $LOAD_PATH.resolve_feature_path. [Feature #15903] [Feature #15230]

Stdlib updates (outstanding ones only)

Bundler
CGI
  • CGI.escapeHTML becomes 2~5x faster when there's at least one escaped character.

CSV
Date
Delegator
  • Object#DelegateClass accepts a block and module_evals it in the context of the returned class, similar to Class.new and Struct.new.

ERB
  • Prohibit marshaling ERB instance.

IRB
  • Introduce syntax highlight inspired by pry.gem to Binding#irb source lines, REPL input, and inspect output of some core-class objects.

  • Introduce multiline mode by Reline.

  • Show documents when completion.

  • Enable auto indent and save/load history by default.

Net::FTP
  • Add features and options. [Feature #15964]

Net::IMAP
  • Add Server Name Indication (SNI) support. [Feature #15594]

open-uri
  • Warn open-uri's “open” method at Kernel. Use URI.open instead. [Misc #15893]

  • The default charset of text/* media type is UTF-8 instead of ISO-8859-1. [Bug #15933]

Pathname
Racc
  • Merge 1.4.15 from upstream repository and added cli of racc.

Reline
  • New stdlib that is compatible with readline stdlib by pure Ruby and also has a multiline mode.

RSS
RubyGems

Compatibility issues (excluding feature bug fixes)

Stdlib compatibility issues (excluding feature bug fixes)

profile.rb, Profiler__
  • Removed from standard library. No one maintains it from Ruby 2.0.0.

C API updates

* C API declarations with `ANYARGS` are changed not to use `ANYARGS`
  https://github.com/ruby/ruby/pull/2404

Implementation improvements

Fiber
  • Allow selecting different coroutine implementation by using `–with-coroutine=`, e.g.

    ./confgure --with-coroutine=ucontext
    ./confgure --with-coroutine=copy
  • Replace previous stack cache with fiber pool cache. The fiber pool allocates many stacks in a single memory region. Stack allocation becomes O(log N) and fiber creation is amortized O(1). Around 10x performance improvement was measured in micro-benchmarks.

Thread
  • VM stack memory allocation is now combined with native thread stack, improving thread allocation performance and reducing allocation related failures. ~10x performance improvement was measured in micro-benchmarks.

JIT
  • JIT-ed code is recompiled to less-optimized code when an optimization assumption is invalidated.

  • Method inlining is performed when a method is considered as pure. This optimization is still experimental and many methods are NOT considered as pure yet.

  • Default value of --jit-max-cache is changed from 1,000 to 100

  • Default value of --jit-min-calls is changed from 5 to 10,000

Miscellaneous changes