[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

Re: SyncEnumerator

SER

11/9/2004 1:07:00 PM

On Sunday 07 November 2004 17:49, Yukihiro Matsumoto wrote:
> on Mon, 8 Nov 2004 04:08:36 +0900, gabriele renzi
> > |but /just/ making something faster seems a ruby-core thing, cause it
> > |is
> > |better in everyone's point of view (well, except for making
> > |sleep()
> > | faster)
>
> I thing making something faster without changing behavior would do
> nothing with RCR from the beginning.

Ok. Then I'd like to suggest replacing the existing SyncEnumerator in
Generator.rb with the one I've provided.

--
### SER
### Deutsch|Esperanto|Francaise|Linux|XML|Java|Ruby|Aikido
### http://www.germane-softwar... jabber.com:ser ICQ:83578737
### GPG: http://www.germane-softwar.../Security/ser_public.gpg
3 Answers

Carlos

11/10/2004 12:17:00 PM

0

["Sean E. Russell" <ggg@ser1.net>, 2004-11-09 14.06 CET]
> Ok. Then I'd like to suggest replacing the existing SyncEnumerator in
> Generator.rb with the one I've provided.

But:

class SyncEnumerator2
...
end

f = File.new("/etc/passwd")
g = 0..10
SyncEnumerator2.new(f, g).each do |line, nr| print nr, ": ", line end

produces:

p.rb:11:in `initialize': undefined method `size' for #<File:/etc/passwd> (NoMethodError)
from p.rb:11:in `each'
from p.rb:11:in `initialize'
from p.rb:37:in `new'
from p.rb:37

--


Jonathan Paisley

11/10/2004 12:43:00 PM

0

On Tue, 09 Nov 2004 22:06:58 +0900, Sean E. Russell wrote:

> On Sunday 07 November 2004 17:49, Yukihiro Matsumoto wrote:
>> I thing making something faster without changing behavior would do
>> nothing with RCR from the beginning.
>
> Ok. Then I'd like to suggest replacing the existing SyncEnumerator in
> Generator.rb with the one I've provided.

Is the SyncEnumerator method 'end?' from the original implementation in
generator.rb part of the public interface? If so, is it okay that the
proposed alternative doesn't provide it?

Another difference that may be worth considering is that the
non-continuation based implementation can't (I think - please correct me
here) handle Enumerables that can only be enumerated once. An example
would be a file, socket or a pipe.

SyncEnumerator1 uses [] to index the Enumerable, so it would be
necessary to update the documentation to explicitly indicate that objects
supporting [] are required. The same applies for the use of the 'size'
method.

SyncEnumerator2 uses zip which converts to arrays internally if necessary.
What are the memory implications of using SyncEnumerator2 as opposed to
the current SyncEnumerator with, for example, two very large files?


I suppose the above boils down to: the SyncEnumerator improvements
primarily apply to array-like objects, so I'd like to see the
Generator-based implementation remain, somewhere.

Thanks.

T. Onoma

11/10/2004 1:36:00 PM

0

On Wednesday 10 November 2004 07:53 am, Jonathan Paisley wrote:
| Is the SyncEnumerator method 'end?' from the original implementation in
| generator.rb part of the public interface? If so, is it okay that the
| proposed alternative doesn't provide it?

Speaking of which, I tend to think #begin and #end, and the like named methods
make terrible method names. Do others agree? Should these be dprecated in
favor of others?

T.