Zulip Chat Archive
Stream: general
Topic: Which HashMap implementation should I use?
nrs (Nov 13 2024 at 18:10):
According to Loogle, there's Std.HashMap
, Lean.HashMap
, and Batteries.HashMap
. Is there any one of these that is recommended to use, or better suited for particular purposes? Or are they pretty much the same?
Damiano Testa (Nov 13 2024 at 18:18):
One of the two should be deprecated: if you used one and you did not get a deprecation, you're using the correct one!
nrs (Nov 13 2024 at 18:19):
I see, thank you!!
Eric Wieser (Nov 13 2024 at 18:21):
None of them are deprecated in mathlib master as far as I can tell
nrs (Nov 13 2024 at 18:24):
can confirm that importing these and using #print
on their names does not report any deprecation notice
Damiano Testa (Nov 13 2024 at 18:24):
Ooh then I misremember: I thought that I had some deprecation about them, but maybe it was hashset then?
Damiano Testa (Nov 13 2024 at 18:25):
#print
may not be enough to trigger a deprecation (#check
is not enough, print... Maybe!)
Shreyas Srinivas (Nov 13 2024 at 18:25):
Std.HashMap has all the nice lemmas iirc
David Renshaw (Nov 13 2024 at 18:26):
https://leanprover-community.github.io/mathlib4_docs/Lean/Data/HashMap.html#Lean.HashMap
David Renshaw (Nov 13 2024 at 18:26):
^ looks deprecated to me
Eric Wieser (Nov 13 2024 at 18:26):
import Batteries
def a : Std.HashMap Nat Nat := sorry
def b : Lean.HashMap Nat Nat := sorry
def c : Batteries.HashMap Nat Nat := sorry
David Renshaw (Nov 13 2024 at 18:26):
Eric Wieser (Nov 13 2024 at 18:26):
Indeed, the deprecation shows up if you don't use #check
nrs (Nov 13 2024 at 18:30):
tyvm for answers!! hm, if Std.HashMap
has more lemmas, is there any reason to use Batteries.HashMap
?
Damiano Testa (Nov 13 2024 at 19:59):
Damiano Testa said:
#check
is not enough, print... Maybe!)
Here is a similar discussion about deprecation and #check
.
Kim Morrison (Nov 14 2024 at 01:54):
Please only use Std.HashMap
going forward!
Kim Morrison (Nov 14 2024 at 01:55):
https://leanprover.zulipchat.com/#narrow/channel/348111-batteries/topic/Unifying.20.60Batteries.2EHashMap.60.20and.20.60Std.2EHashMap.60.2E/near/477103618 is my proposal for a deprecation path for Batteries.HashMap.
nrs (Nov 14 2024 at 02:23):
Will do, ty for answer!
Last updated: May 02 2025 at 03:31 UTC