On Aug 3, 8:06 pm, Mark Engelberg <mark.engelb...@gmail.com> wrote:
> So if you want to make 10 changes to a vector, would it be worthwhile
> to turn it into a transient, make the 10 changes, and then turn it
> back to persistent?  If no, then 100 changes?  1000?
>
> In other words, how much overhead is there in the transformation back
> and forth, and therefore, about how much transient work does it take
> before it becomes worth doing?

If you are going to make 10 changes once ever in an application, then
don't bother making your code uglier. If you are going to make 10
changes in a function that gets called a lot, it will not be slower to
use transients. It may not be faster depending on the locality of the
changes (i.e. 10 evenly distributed assocs in a large vector would be
a wash, 10 conj! calls definitely much faster.

In short, the O(1) overhead is less than the cost of even a single
edit. So, e.g. into/vec/vector now use transients unconditionally if
possible.

Rich

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to