Re: defrecord, equality, hashing, and performance

2015-06-13 Thread Mike Rodriguez
Thanks for the insight Alex! -- 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

Re: defrecord, equality, hashing, and performance

2015-06-12 Thread Mars0i
On Thursday, June 11, 2015 at 2:19:56 PM UTC-5, Andy Fingerhut wrote: You can override hashCode and/or hasheq methods in deftype. I've been unable to do it. Is there something special needed to allow this to work? user= (defrecord Foo [x] Object (hashCode [this] 42)) CompilerException

Re: defrecord, equality, hashing, and performance

2015-06-12 Thread Mark Engelberg
Related to this, another thing I would like Clojure to provide is an easy way to opt-in for map-like function application for defrecords. Right now, Clojure doesn't implement function application for records, and it is a glaring incompatibility that causes bugs when you switch back and forth

Re: defrecord, equality, hashing, and performance

2015-06-12 Thread Mark Engelberg
So just to explain this a little more, recently I wanted something record-like with custom hashing and equality for my ubergraph library. Unfortunately, you can't do this with defrecord, and starting from deftype and re-implementing all the map-like semantics from scratch is a total pain. So what

Re: defrecord, equality, hashing, and performance

2015-06-12 Thread Mars0i
On Thursday, June 11, 2015 at 2:12:12 PM UTC-5, puzzler wrote: Zach Tellman's potemkin library includes several useful ways to tweak deftypes and defrecords. I wish Clojure itself provided more ways to do this, but in the meantime, potemkin is the best way to create something custom, like

Re: defrecord, equality, hashing, and performance

2015-06-12 Thread Andy Fingerhut
deftype allows you to override hashCode and/or hasheq (I believe defaulting to identity-based implementations from java.lang.Object). defrecord does not. As mentioned in another message, potemkin may provide easier building blocks to build on than deftype. Andy On Thu, Jun 11, 2015 at 11:10

Re: defrecord, equality, hashing, and performance

2015-06-12 Thread Sun Ning
-BEGIN PGP SIGNED MESSAGE- Hash: SHA256 Prismatic has some document for deftype/defrecord/map, hope it's useful to you: https://github.com/Prismatic/eng-practices/blob/master/clojure/20130926-data-representation.md On 06/12/2015 02:36 AM, Mars0i wrote: I think that the following is all

Re: defrecord, equality, hashing, and performance

2015-06-12 Thread Alex Miller
Re IFn support for defrecord, I don't actually know the reason that's not built-in. I am not aware of an existing ticket for this. Of course, at this point many people patch it in, so we would need to consider potential breakage from that. -- You received this message because you are

Re: defrecord, equality, hashing, and performance

2015-06-12 Thread Fluid Dynamics
On Friday, June 12, 2015 at 11:46:17 AM UTC-4, Mars0i wrote: Oh, yes, and that's an interesting idea to wrap a record in an atom or delay. For my present uses that would be more trouble than it's worth, but it's something worth keeping in mind for other situations. Putting a unique

Re: defrecord, equality, hashing, and performance

2015-06-12 Thread Mars0i
On Friday, June 12, 2015 at 1:34:20 AM UTC-5, Andy Fingerhut wrote: deftype allows you to override hashCode and/or hasheq (I believe defaulting to identity-based implementations from java.lang.Object). defrecord does not. Sorry--I misread your earlier statement about this. That's good to

Re: defrecord, equality, hashing, and performance

2015-06-12 Thread Mars0i
Oh, yes, and that's an interesting idea to wrap a record in an atom or delay. For my present uses that would be more trouble than it's worth, but it's something worth keeping in mind for other situations. On Friday, June 12, 2015 at 10:41:57 AM UTC-5, Mars0i wrote: puzzler, thanks for the

Re: defrecord, equality, hashing, and performance

2015-06-12 Thread Mars0i
puzzler, thanks for the explanation about how you built on potemkin's map options. Probably not useful for my current application--easier to just work around deftype's limitations on an ad-hoc basis. But that takes some of the fun (convenience) out of Clojure (and unnecessarily, I feel, I

Re: defrecord, equality, hashing, and performance

2015-06-12 Thread Alex Miller
I bumped up the priority on CLJ-1224 to make sure it got pulled into 1.8 (based on being reminded about it here). I don't expect it to be included in 1.7. On Thursday, June 11, 2015 at 9:30:21 PM UTC-5, Mike Rodriguez wrote: I agree the hashCode performance for records is a concern due to

Re: defrecord, equality, hashing, and performance

2015-06-11 Thread Mark Engelberg
Zach Tellman's potemkin library includes several useful ways to tweak deftypes and defrecords. I wish Clojure itself provided more ways to do this, but in the meantime, potemkin is the best way to create something custom, like a deftype that behaves mostly like defrecord with some different

Re: defrecord, equality, hashing, and performance

2015-06-11 Thread Andy Fingerhut
You can override hashCode and/or hasheq methods in deftype. If the reason that defrecord hashing is slow in your application is because hashed recalculates the hash values from scratch each time, without hashing, consider voting for this ticket so that is improved in the future:

Re: defrecord, equality, hashing, and performance

2015-06-11 Thread Andy Fingerhut
Ugh. Too many typos there. Here is what I meant: If the reason that defrecord hashing is slow in your application is because _hasheq_ recalculates the hash values from scratch each time, without _caching the value_, consider voting for this ticket so that is improved in the future:

Re: defrecord, equality, hashing, and performance

2015-06-11 Thread Mark Engelberg
Yes, please vote for that issue. I find myself frequently having to work around this limitation of records in Clojure; I mostly avoid using records directly as a consequence of this performance issue. As a side note, one quick-and-dirty way to get identity semantics for your data is to wrap each

Re: defrecord, equality, hashing, and performance

2015-06-11 Thread Mike Rodriguez
I agree the hashCode performance for records is a concern due to that lack of caching. I noticed the priority of that Jira 1224 changed to critical about a week ago (June 3). I was curious why that was done and what that means in terms of prioritization. Last minute squeeze into CLJ version