Re: Transducers improve performance more than expected

2016-05-10 Thread Alex Miller
range is reducible and boils down to just a local loop in most cases, so shouldn't create any heap garbage (well, other than whatever your reducing function does). See: https://github.com/clojure/clojure/blob/master/src/jvm/clojure/lang/LongRange.java#L229-L238 Additionally, it can act as a ch

Re: Transducers improve performance more than expected

2016-05-10 Thread Timothy Baldridge
In addition, as of 1.7, (range 1000) no longer creates a lazy sequence. It creates something that acts a bit like a sequence, but is reducable. So doing something like (reduce + 0 (range 1000)) is super fast and creates almost no garbage at all. On Tue, May 10, 2016 at 5:46 PM, Alan Thompson wrot

Re: Transducers improve performance more than expected

2016-05-10 Thread Alan Thompson
I don't understand what you mean. '(range 1000)' produces a lazy sequence, and '(reduce + ...)' doesn't hold onto the head of the lazy sequence. Therefore, each element can be GC'd as soon as added into the running total, the the lazy sequence only produces new elements as they are requested by the

Re: Transducers improve performance more than expected

2016-05-10 Thread JvJ
That brings me to another thing I've wondered about. It is a typical clojure idiom to do something like (reduce + (range 1000)). But, unlike imperative loops, this will cache all those 1000 elements. This can kind of bloat memory, especially with large sequences? How can you get around it (ot

Re: Transducers improve performance more than expected

2016-05-10 Thread Alex Miller
Because some of the time you don't want caching. For example, if you want to (later) reduce over a large (larger than memory even) external resource. eductions allow you to define the source in one spot but defer the (eager) reduction until later. On Tuesday, May 10, 2016 at 11:22:24 AM UTC-5,

Re: Transducers improve performance more than expected

2016-05-10 Thread JvJ
In that case, why aren't eductions just lazy sequences? On Monday, 9 May 2016 16:07:55 UTC-7, Alex Miller wrote: > > eductions are non-caching (will re-perform their work each time they are > used), so most of the time I would say lazy sequences are preferable. > > On Monday, May 9, 2016 at 4:54:

Re: Serialising/deserialising mixed Clojure and Java datastructures

2016-05-10 Thread 'Simon Brooke' via Clojure
On Tuesday, 10 May 2016 10:11:58 UTC+1, Simon Brooke wrote: > > On Monday, 9 May 2016 16:55:59 UTC+1, Alex Miller wrote: >> >> Clojure is designed with enough extensibility to modify the printer and >> reader to cover this case. >> >> You can define a custom print strategy for these types by exten

Re: Serialising/deserialising mixed Clojure and Java datastructures

2016-05-10 Thread 'Simon Brooke' via Clojure
On Monday, 9 May 2016 16:55:59 UTC+1, Alex Miller wrote: > > Clojure is designed with enough extensibility to modify the printer and > reader to cover this case. > > You can define a custom print strategy for these types by extending the > print-dup multimethod. If you print it as a tagged litera

Clojure in Scripting Engine JSR-223

2016-05-10 Thread Olek
Is Clojure compilant with scripting engine API (JSR-223)? Last notes are from 2009. Thanks in advance, Olek -- 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