Issue #7440 has been reported by yhara (Yutaka HARA). ---------------------------------------- Bug #7440: IO#lines etc. should return Array https://bugs.ruby-lang.org/issues/7440 Author: yhara (Yutaka HARA) Status: Open Priority: Normal Assignee: yhara (Yutaka HARA) Category: core Target version: 2.0.0 ruby -v: ruby 2.0.0dev (2012-11-26 trunk 36708) [x86_64-darwin12.2.1] String#bytes, #chars, #codepints and #lines are changed to return Array in #6670. For consistent behavior, following methods should return Array too: * ARGF.lines, chars, bytes, codepoints * IO#lines, chars, bytes, codepoints * StringIO#lines, chars, bytes, codepoints * Zlib::GzipReader#lines, bytes Please let me know if there are more.
on 2012-11-26 16:47
on 2012-11-26 17:50
Issue #7440 has been updated by headius (Charles Nutter).
Is this really wnat you'd want? ARGF and IO (and possibly Zlib's
readers) can stream data lazily in lines/chars/bytes/codepoints, where
forcing them to an Array would have to eagerly read everything (and
potentially block).
irb(main):001:0> io = File.open('Makefile')
=> #<File:Makefile>
irb(main):002:0> lines = io.lines
=> #<Enumerator: #<File:Makefile>:lines>
irb(main):003:0> lines.next
=> "SHELL = /bin/sh\n"
irb(main):004:0> io.pos
=> 16
irb(main):005:0> lines.next
=> "NULLCMD = :\n"
irb(main):006:0> io.pos
=> 28
irb(main):007:0> lines.to_a; nil
=> nil
irb(main):008:0> io.pos
=> 12737
----------------------------------------
Bug #7440: IO#lines etc. should return Array
https://bugs.ruby-lang.org/issues/7440#change-33970
Author: yhara (Yutaka HARA)
Status: Open
Priority: Normal
Assignee: yhara (Yutaka HARA)
Category: core
Target version: 2.0.0
ruby -v: ruby 2.0.0dev (2012-11-26 trunk 36708) [x86_64-darwin12.2.1]
String#bytes, #chars, #codepints and #lines are changed to return Array
in #6670.
For consistent behavior, following methods should return Array too:
* ARGF.lines, chars, bytes, codepoints
* IO#lines, chars, bytes, codepoints
* StringIO#lines, chars, bytes, codepoints
* Zlib::GzipReader#lines, bytes
Please let me know if there are more.
on 2012-11-26 18:30
Issue #7440 has been updated by drbrain (Eric Hodel). With the exception of StringIO hey also support infinite streams. I think the current Enumerator is best. ---------------------------------------- Bug #7440: IO#lines etc. should return Array https://bugs.ruby-lang.org/issues/7440#change-33973 Author: yhara (Yutaka HARA) Status: Open Priority: Normal Assignee: yhara (Yutaka HARA) Category: core Target version: 2.0.0 ruby -v: ruby 2.0.0dev (2012-11-26 trunk 36708) [x86_64-darwin12.2.1] String#bytes, #chars, #codepints and #lines are changed to return Array in #6670. For consistent behavior, following methods should return Array too: * ARGF.lines, chars, bytes, codepoints * IO#lines, chars, bytes, codepoints * StringIO#lines, chars, bytes, codepoints * Zlib::GzipReader#lines, bytes Please let me know if there are more.
on 2012-11-26 19:51
Issue #7440 has been updated by Eregon (Benoit Daloze). drbrain (Eric Hodel) wrote: > With the exception of StringIO hey also support infinite streams. I think the current Enumerator is best. Strongly agreed. It could also increase a lot the memory usage (while on String we anyway already have the whole String in memory so it is less of a concern). File.open('/usr/share/dict/words').lines.each_with_object(Hash.new(0)) { |word, count| count[word[0].downcase] += 1 } ---------------------------------------- Bug #7440: IO#lines etc. should return Array https://bugs.ruby-lang.org/issues/7440#change-33975 Author: yhara (Yutaka HARA) Status: Open Priority: Normal Assignee: yhara (Yutaka HARA) Category: core Target version: 2.0.0 ruby -v: ruby 2.0.0dev (2012-11-26 trunk 36708) [x86_64-darwin12.2.1] String#bytes, #chars, #codepints and #lines are changed to return Array in #6670. For consistent behavior, following methods should return Array too: * ARGF.lines, chars, bytes, codepoints * IO#lines, chars, bytes, codepoints * StringIO#lines, chars, bytes, codepoints * Zlib::GzipReader#lines, bytes Please let me know if there are more.
on 2012-11-27 04:18
Issue #7440 has been updated by yhara (Yutaka HARA). Eregon (Benoit Daloze) wrote: > Strongly agreed. It could also increase a lot the memory usage (while on String we anyway already have the whole String in memory so it is less of a concern). > > File.open('/usr/share/dict/words').lines.each_with_object(Hash.new(0)) { |word, count| count[word[0].downcase] += 1 } In that case you can use IO#each_line, which still returns Enumerator. File.open('/usr/share/dict/words').each_line.with_object(Hash.new(0)) { |word, count| count[word[0].downcase] += 1 } But in other words, we need to replace uses of IO#lines to IO#each_line, or our existing Ruby program may have performance problem with 2.0.0... # Ticket #6670 is reopened. Please continue discussion there http://bugs.ruby-lang.org/issues/6670 ---------------------------------------- Bug #7440: IO#lines etc. should return Array https://bugs.ruby-lang.org/issues/7440#change-34002 Author: yhara (Yutaka HARA) Status: Open Priority: Normal Assignee: yhara (Yutaka HARA) Category: core Target version: 2.0.0 ruby -v: ruby 2.0.0dev (2012-11-26 trunk 36708) [x86_64-darwin12.2.1] String#bytes, #chars, #codepints and #lines are changed to return Array in #6670. For consistent behavior, following methods should return Array too: * ARGF.lines, chars, bytes, codepoints * IO#lines, chars, bytes, codepoints * StringIO#lines, chars, bytes, codepoints * Zlib::GzipReader#lines, bytes Please let me know if there are more.
on 2012-11-30 17:57
Issue #7440 has been updated by yhara (Yutaka HARA). Status changed from Open to Rejected This issue is now included in #6670. ---------------------------------------- Bug #7440: IO#lines etc. should return Array https://bugs.ruby-lang.org/issues/7440#change-34227 Author: yhara (Yutaka HARA) Status: Rejected Priority: Normal Assignee: yhara (Yutaka HARA) Category: core Target version: 2.0.0 ruby -v: ruby 2.0.0dev (2012-11-26 trunk 36708) [x86_64-darwin12.2.1] String#bytes, #chars, #codepints and #lines are changed to return Array in #6670. For consistent behavior, following methods should return Array too: * ARGF.lines, chars, bytes, codepoints * IO#lines, chars, bytes, codepoints * StringIO#lines, chars, bytes, codepoints * Zlib::GzipReader#lines, bytes Please let me know if there are more.
Please log in before posting. Registration is free and takes only a minute.
Existing account
(Switch to SSL-encrypted connection)
NEW: Do you have a Google/GoogleMail or Yahoo account? No registration required!
Log in with Google account | Log in with Yahoo account
Log in with Google account | Log in with Yahoo account
No account? Register here.