Re: Schrodinger's cat in clojure?

2014-10-11 Thread Mars0i
Jan-Paul, Laurent- That's great. Thanks. -- 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 unsub

Re: Recursive codec/frames in gloss? -- SOLVED

2014-10-11 Thread Ken Restivo
Solved: (g/header (g/repeated :ubyte :prefix :ubyte) (fn [h] (g/finite-block (apply + h))) (fn [b] ...)) That did it. On Fri, Oct 10, 2014 at 10:32:59AM -0700, john walker wrote: > What information do you want after this is decoded?

Re: Recursive codec/frames in gloss?

2014-10-11 Thread Ken Restivo
Correction: this actually is what I'm trying to do: (defn get-payload-from-recursive-header-frame [[hlenlen & raw-bytes]] (let [hlen (apply + (take hlenlen raw-bytes))] (take hlen (drop hlenlen raw-bytes Or with the headers preserved: (defn get-payload-from-recursive-header-f

Re: Why is my function faster with eval?

2014-10-11 Thread Mike Fikes
Hey Michael, Since your eval solution essentially "cookie-cutters" out maps, each with the same keys, as fast as it can, I was playing around with what would happen if you used records, and I cobbled together something that appears to run twice as fast as the eval approach: (defn read-to-struc

Re: Keyword comparison performance

2014-10-11 Thread Mike Rodriguez
Thanks for taking the time for the (detailed) clarification. I understand what you were saying now. :) -- 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 ar

Re: [ANN]: clojure.jdbc 0.3.0 - A jdbc library for clojure (previously clj.jdbc)

2014-10-11 Thread Daniel
+1 for changing the name to something which people won't confuse with the "blessed" library. On Saturday, October 11, 2014 3:39:43 PM UTC-5, James Reeves wrote: > > The name of this library is *really* close to the "clojure.java.jdbc" > contrib library. You may want to consider changing the name

Re: Keyword comparison performance

2014-10-11 Thread Andy Fingerhut
The common case in hash map lookup for keywords _that finds a matching key in the map_ is: (a) hash the keyword (fast, because it is cached) (b) use the hash code value to walk one or more nodes in a tree to reach a leaf, where there can be a single value, or a linked list of multiple colliding va

Re: [ANN] async-sockets - work with sockets using core.async channels

2014-10-11 Thread Julian
Hi Zach, Thanks for the clarity of thought that went into this post. Perhaps it is obvious to everyone but me, but I saw this post by Christophe Grande yesterday that appears to address these concerns: "Back-pressurized interop for core.async" https://twitter.com/cgrand/status/520566182194450

Re: Recursive codec/frames in gloss?

2014-10-11 Thread Ken Restivo
After this is decoded, I want the the payload, and it'd be nice to have the length too but not necessary. Described in clojure instead of prose: (defn get-payload-from-recursive-header-frame [[hlenlen & raw-bytes]] (let [hlen (apply + (take hlenlen raw-bytes))] (drop hlenlen raw-bytes)))

Re: Keyword comparison performance

2014-10-11 Thread Mike Rodriguez
To the point (b) it seems that this posts is saying the clj's = will not be faster for keyword than string since the runtime type checking overhead is where most time is spent. So the identity part of keyword equals doesn't show its benefit here (unless these were long strings vs long keywords I

Re: Keyword comparison performance

2014-10-11 Thread Mike Rodriguez
To the point (b) it seems that this posts is saying the clj's = will not be faster for keyword than string since the runtime type checking overhead is where most time is spent. So the identity part of keyword equals doesn't show its benefit here (unless these were long strings vs long keywords I

Re: Keyword comparison performance

2014-10-11 Thread Mike Rodriguez
To the point (b) it seems that this posts is saying the clj's = will not be faster for keyword than string since the runtime type checking overhead is where most time is spent. So the identity part of keyword equals doesn't show its benefit here (unless these were long strings vs long keywords I

Re: Keyword comparison performance

2014-10-11 Thread David Nolen
Advantages exist, ClojureScript and Clojure both use the most efficient equality check during key lookup in maps. On Saturday, October 11, 2014, Colin Fleming wrote: > Does this mean that keywords don't have any efficiency advantages over > strings when used as map keys? > > On 12 October 2014 0

Re: Keyword comparison performance

2014-10-11 Thread Andy Fingerhut
I haven't taken the time to verify these statements with microbenchmarks, but there are 2 reasons why keywords should have efficiency advantages over strings when used as hash map keys: (a) For keywords, hash values are calculated and cached when the keyword is first constructed. When looking up

Re: [ANN]: clojure.jdbc 0.3.0 - A jdbc library for clojure (previously clj.jdbc)

2014-10-11 Thread Andrey Antukh
Thank you very much to both for the feedback. I was considered different names in the past (I don't like much clj.jdbc name :( ) and the current name was the election. Changing the name again also can get confuse people, because of it, I thinking maybe better keep the current name as is. Thanks a

Re: Keyword comparison performance

2014-10-11 Thread Colin Fleming
Does this mean that keywords don't have any efficiency advantages over strings when used as map keys? On 12 October 2014 02:25, David Nolen wrote: > As already mentioned use identical? In ClojureScript you must use > keyword-identical? for fast comparisons. > > > On Friday, October 10, 2014, Jon

Re: Schrodinger's cat in clojure?

2014-10-11 Thread Laurent PETIT
Le samedi 11 octobre 2014, Jan-Paul Bultmann a écrit : > Yes you are right, currently a lot of stuff is seq only. > I think that reducers provide a lot of eager operations, but not > everything. > > So yeah, transducers are exactly what you are looking for. > > If you call `sequence` with the tra

Re: [ANN]: clojure.jdbc 0.3.0 - A jdbc library for clojure (previously clj.jdbc)

2014-10-11 Thread Michael Klishin
 On 12 October 2014 at 00:39:40, James Reeves (ja...@booleanknot.com) wrote: > The name of this library is really close to the "clojure.java.jdbc" > contrib library. You may want to consider changing the name so > people don't get confused. …and IMO clj.jdbc was significantly easier to tell fr

Re: [ANN]: clojure.jdbc 0.3.0 - A jdbc library for clojure (previously clj.jdbc)

2014-10-11 Thread James Reeves
The name of this library is *really* close to the "clojure.java.jdbc" contrib library. You may want to consider changing the name so people don't get confused. - James On 11 October 2014 21:01, Andrey Antukh wrote: > A JDBC library for clojure. > > Previously: clj.jdbc > > Summary of changes fr

[ANN]: clojure.jdbc 0.3.0 - A jdbc library for clojure (previously clj.jdbc)

2014-10-11 Thread Andrey Antukh
A JDBC library for clojure. Previously: clj.jdbc Summary of changes from 0.2.2 to 0.3.0: - Minor code reorganization (split protocols from implementation) - Normalize connection pool parameters make them more plugable. - Type hints for almost all code. - Documentation improvements. Summary of c

[ANN] ike.tk.httpkit 0.1.0 - Trapperkeeper service for http-kit

2014-10-11 Thread Andrew Oberstar
Just released v0.1.0 of ike.tk.http which provides a Trapperkeeper service that starts http-kit. The http-kit-service expects another service implementing the HandlerService protocol to provide the Ring handler. This is my very first Clojure experience, so any feedback is welcome. More details, i

Re: Schrodinger's cat in clojure?

2014-10-11 Thread Jan-Paul Bultmann
Yes you are right, currently a lot of stuff is seq only. I think that reducers provide a lot of eager operations, but not everything. So yeah, transducers are exactly what you are looking for. If you call `sequence` with the transducer you get laziness, if you call `into` with a collection and a

Re: Schrodinger's cat in clojure?

2014-10-11 Thread Mars0i
I don't think I have any misconceptions. I probably haven't expressed myself clearly. Clojure has many very useful functions that return lazy sequences. Analogous functions in other languages perform what are exactly the same operations, except for the fact that what's returned is not a lazy

Re: Schrodinger's cat in clojure?

2014-10-11 Thread Mars0i
I don't think I have any misconceptions. I probably haven't expressed myself clearly. Clojure has many very useful functions that return lazy sequences. Analogous functions in other languages perform what are exactly the same operations, but for the fact that what's returned is not a lazy se

Re: Schrodinger's cat in clojure?

2014-10-11 Thread Lee Spector
On Oct 11, 2014, at 1:00 PM, Jan-Paul Bultmann wrote: > > Therefor "turning of laziness" makes no real sense. You could say "disable > the laziness of seqs", > but that doesn't really make sense either. It's like disabling the FIFO > nature of a queue or a channel. > If you don't want the pro

Re: Schrodinger's cat in clojure?

2014-10-11 Thread Jan-Paul Bultmann
I feel that there are some misconceptions here, Clojure is not a language that has lazy evaluation, but is instead completely eager. Macros are the closest thing that come to laziness, but they are still different. However, Clojure has a data structure, that also serves as an abstraction layer, th

[ANN] rete4frames, v. 5.2.0 - CLIPS-like expert system shell

2014-10-11 Thread ru
Hello all, New version 5.2.0 of rete4frames CLIPS-like expert system shell published on https://github.com/rururu/rete4frames. News: 1. Tests can be used in negative condition 2. Because of this CLIPS examples reducted to canonical form 3. Several bug fixes including logical 4. Lot of code opti

Re: best way to edit EDN value in cljs

2014-10-11 Thread Dylan Butman
you can do some pretty powerful things using update-in and merge-with, especially if combined with protocols or multimethods that determine behavior. Can you give a more specific example of what you're trying to do? deep-merge and deep-merge-with are also useful here. There are a lot of nearly

Re: Schrodinger's cat in clojure?

2014-10-11 Thread Mars0i
Thanks Jan-Paul. That's helpful. I wonder whether, if all lazy functions were rewritten in terms of transducers, it would then be easy to turn laziness on and off. (I am not suggesting that this should be done. No doubt it would entail a lot of work, and performance tradeoffs. I'm quite ha

Re: Keyword comparison performance

2014-10-11 Thread Stephen Gilardi
On Oct 11, 2014, at 10:59 AM, Jony Hudson wrote: > But if any of these Keyword objects were garbage-collected, I think it would > break the parity between identical? and =. The Keyword construction and interning mechanism ensures that whenever there exists at least once (strong) reference to

Re: Keyword comparison performance

2014-10-11 Thread Jony Hudson
Thanks all, that makes a lot of sense. To summarise, if I understand correctly, (on the JVM) comparing with = : - first checks if the objects are one and the same, returns true if so - if not, checks whether they are numbers or persistent collections, which have special-case checks - if neither o

Re: Do this or that

2014-10-11 Thread Mike Fikes
Thanks all! FWIW, the snake game in Programming Clojure has an example (where refs are conditionally updated) which is consistent with the advice given here. Two nice things I noticed in that example: 1. The first form inside do is kept on the same line (a small but nice improvement reducing

Re: Keyword comparison performance

2014-10-11 Thread David Nolen
As already mentioned use identical? In ClojureScript you must use keyword-identical? for fast comparisons. On Friday, October 10, 2014, Jony Hudson wrote: > Hi All, > > I've been optimising a piece of code lately, and have come to wonder > about the performance of keyword comparison. Specifical

Re: Keyword comparison performance

2014-10-11 Thread Mikera
Just done some of my own quick benchmarking on this. (= :foo :bar) ;; 21.7 ns (.equals :foo :bar);; 3.0 ns (identical? :foo :bar) ;; 3.0 ns (.equals "foo" "bar") ;; 5.6 ns (= "foo" "bar");; 24.4 ns This seems to support my suspicion that the overhead is in the extra ove

Re: Keyword comparison performance

2014-10-11 Thread Mikera
I believe this is a symptom of the fact that the Clojure compiler isn't very type aware, and = inserts a bunch of redundant runtime type checks (see clojure.lang.Util.equiv(Object, Object) ) In particular, it always checks for whether the arguments are instances of Number or IPersistentCollecti

Re: Schrodinger's cat in clojure?

2014-10-11 Thread Jan-Paul Bultmann
Transducers build up transformation steps, with new generic operations like single arg `map` and `filter`, and then apply these transformations to a collection using an evaluation function. This function decides if operations are done lazily, eagerly, or on a channel. Note that while this makes