[Coldstuff] .join() vrs. join()
Adam Cormany
coldstuff@cold.org
Mon, 5 Aug 2002 14:54:42 -0700 (PDT)
I understand everything you mean except for your
example (foo.explode().join()). With this example,
wouldn't it be faster or better to do
join(explode(foo))?
--- Brandon Gillespie <brandon@roguetrader.com> wrote:
> Adam Cormany wrote:
> > Is there a time when I should be using .join()
> instead
> > of join() or is this just the users preference? On
> my
> > system at least, join() seems a bit faster than
> > .join():
> >
> > [06:07 PM:/home/s/soth] ;["a", "b"].join();
> > => "a b"
> > [ seconds: 0.000023; operations: 6 ]
> >
> > [06:08 PM:/home/s/soth] ;join(["a", "b"]);
> > => "a b"
> > [ seconds: 0.000007; operations: 6 ]
> >
> > The same goes for explode() and .explode():
> > [06:08 PM:/home/s/soth] ;"a b".explode();
> > => ["a", "b"]
> > [ seconds: 0.000028; operations: 3 ]
> >
> > [06:10 PM:/home/s/soth] ;explode("a b");
> > => ["a", "b"]
> > [ seconds: 0.000012; operations: 3 ]
> >
>
> They are the same code underneath, but are initiated
> differently.
> join() is an operator, similar to '+' and '*' etc.
> So it will be
> initiated MUCH quicker than a native method call
> (.join()) which has a
> method operator '.' followed by looking up the
> method, building the
> frame, then executing the native code. The
> differences you are seeing
> are the differences between these two actions. both
> are nominal,
> however. The method-call syntax is highly useful
> when chaining
> something (foo.explode().join()).
>
> -Brandon
>
> _______________________________________________
> Cold-Coldstuff mailing list
> Cold-Coldstuff@cold.org
> http://web.cold.org/mailman/listinfo/cold-coldstuff
__________________________________________________
Do You Yahoo!?
Yahoo! Health - Feel better, live better
http://health.yahoo.com