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 x namespace for experimental libraries and inthashmap implementation #2209

Closed
wants to merge 3 commits into from

Conversation

alula
Copy link
Member

@alula alula commented Oct 2, 2019

x namespace was suggested by Alex during Discord talk. The hashmap library focuses on hashmap implementations optimized for specific data types eg. int-anything or usecases eg. synchronized/thread safe map.

to-dos:

  • make the API between IntHashMap and hashmap consistent
  • add language-level support for hashmaps and make it use a type-specific implementation if needed. eg.
nummap := hashmap[int]int // creates a hashmap using integer hashmap implementation
strmap := hashmap[string]int // creates a hashmap using default hashmap implementation

nummap[1] = 5
nummap[3] = 6
nummap['test'] = 7 // won't compile
println(nummap[3]) // 6

strmap['abc'] = 5
strmap['def'] = 6
println(nummap['abc]) // 5

@alula
Copy link
Member Author

alula commented Oct 2, 2019

Tests fail due to a compiler bug, depends on #2210 to be fixed.

@dumblob
Copy link
Contributor

dumblob commented Oct 2, 2019

I was unable to recognize which algorithm this int hashmap implements - could you please document it in comments?

Btw. did you take a look at the most recent existing rigorous benchmark of many existing best performing hash tables? The current int hashmap doesn't look that sophisticated to be as performant as are the hashmaps in the linked test from Martin Ankerl.

Also when implementing any hashmap, please consider making it secure (it's one of the V's goals if I'm not mistaken) by randomizing the iteration order - read carefully this discussion about such attacks and possible highly performant mitigations.

@medvednikov is the x namespace meant to become something like from future import ... in Python or the staging/ directory in vanilla Linux?

@@ -0,0 +1,102 @@
new_array
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fns.txt should be removed from the PR. It is a generated file by v -debug

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, please remove fns.txt

@medvednikov medvednikov closed this Oct 2, 2019
@medvednikov medvednikov reopened this Oct 2, 2019
@medvednikov medvednikov closed this Oct 4, 2019
@medvednikov medvednikov reopened this Oct 4, 2019
@medvednikov medvednikov closed this Nov 6, 2019
@medvednikov medvednikov reopened this Nov 6, 2019
@medvednikov medvednikov closed this Nov 6, 2019
dumblob referenced this pull request Dec 30, 2019
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

Successfully merging this pull request may close these issues.

4 participants