Fork me on GitHub
Al Z. Heymer09:09:57

Shouldn't last be much faster on vectors? At least that is what I remembered to read. I did some basic benchmarking and fail to understand my results.

Al Z. Heymer09:09:33

user=> (def r (doall (range 1e+7)))
user=> (let [v (vec r)]
  #_=>   (time (last v))
  #_=>   (time (last r)))
"Elapsed time: 387.154079 msecs"
"Elapsed time: 157.53812 msecs"
user=> (let [v (vec r)]
  #_=>   (time (last r))
  #_=>   (time (last v)))
"Elapsed time: 277.38866 msecs"
"Elapsed time: 559.517154 msecs"

Al Z. Heymer09:09:52

I realized range, so that I really deal on the data instead of the realization. However, using last on a list seems to be way faster than on the preallocated vector . Does anyone have an explanation for that?


On the contrary - last doesn't check its argument's concrete type, so it traverses the whole structure. What's faster for vectors is peek.

👍 1
Al Z. Heymer09:09:50

Oh! So I misunderstood. Then why is it much slower to traverse the vector?

Alex Miller (Clojure team)13:09:38

Btw by using 1e+7 (a double) you get the nonoptimized version of range that works on longs

Alex Miller (Clojure team)13:09:43

you also want to run these many times to avoid jvm jit effects


I’m expecting that the wild variations in time are due to the JVM effects. is ideal for this (documentation on the page)


is there a way to “bake-in” a java argument when building an uberjar? I want to basically have java -jar mything.jar turn into java -jar -DsomeSetting=thing mything.jar. I tried setting the system property from the first clojure ns that gets loaded, but it behaves differently when I do that

Joshua Suskalo14:09:18

jdeploy also serves a bit of a different purpose as its output isn't a jar file, which may be a dealbreaker in some usecases.

Benjamin C20:09:26

Is there a way to see how much host interop a library with it's dependencies has?

Benjamin C20:09:28

Main motivation would be a rough estimate of how much work it would take to port to clojure/script/dart/clojurl/jank-lang etc.

Joshua Suskalo14:09:48

That feels like something you might be able to do with #clj-kondo analysis

Alex Miller (Clojure team)20:09:48

iff is an abbreviation used in math for “if and only if”

themoreyouknow 6
Alex Miller (Clojure team)20:09:03

that is its intent here


ah my bad sorry


For clojure.test.check generators, how to generate a bigint only, no longs?


Could you use gen/fmap to perform type conversion?


size-bounded-bigint generator seems to have this option, i just don’t know the syntax for it


i just want to know how to pass in force-bigint?


that example is the same as what I did, it generate both longs and bigints


I think this should work for you.

(def gen-bigint (gen/such-that
                 #(= clojure.lang.BigInt (type %))


thx, will go with this for now