Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for golang 1.18 generics #98

Closed
druvv opened this issue Mar 22, 2022 · 4 comments
Closed

Add support for golang 1.18 generics #98

druvv opened this issue Mar 22, 2022 · 4 comments

Comments

@druvv
Copy link

druvv commented Mar 22, 2022

Are we planning to add support for 1.18 generics? Would a PR adding generics be accepted?

@yangcheng
Copy link

that's a great idea, I am happy to contribute too!

@bpowers
Copy link

bpowers commented Apr 3, 2022

I converted a fork of this repo I'm playing with to generics in bpowers@3b54b7d -- it resulted in a 25% performance improvement because the benchmarks no longer had to allocate when passing ints to interface{} parameters (cc @armon):

$ benchstat old.txt new.txt
name        old time/op    new time/op    delta
LRU_Rand-8     226ns ± 2%     167ns ± 1%   -26.18%  (p=0.008 n=5+5)
LRU_Freq-8     214ns ± 0%     164ns ± 0%   -23.57%  (p=0.008 n=5+5)

name        old alloc/op   new alloc/op   delta
LRU_Rand-8     23.0B ± 0%      0.0B       -100.00%  (p=0.008 n=5+5)
LRU_Freq-8     23.0B ± 0%      0.0B       -100.00%  (p=0.008 n=5+5)

name        old allocs/op  new allocs/op  delta
LRU_Rand-8      2.00 ± 0%      0.00       -100.00%  (p=0.008 n=5+5)
LRU_Freq-8      2.00 ± 0%      0.00       -100.00%  (p=0.008 n=5+5)

container libraries like this are the perfect candidate for generics.

@hyahm
Copy link

hyahm commented Apr 29, 2022

Maybe you can try this: https://github.com/hyahm/gocache

@jefferai
Copy link
Member

v2 supports generics.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants