Skip to content

Instantly share code, notes, and snippets.

/kwargs.rb Secret

Created February 19, 2016 17:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/0f7b3a92894b86d41c19 to your computer and use it in GitHub Desktop.
Save anonymous/0f7b3a92894b86d41c19 to your computer and use it in GitHub Desktop.
handling keyword args
jupiter:~/JAVA/swf-converter-conversion-node$ time ruby -le '
def foo(*args, **kwargs)
kwargs
end
10000.times { foo(1,2,3,{a:1, b: 2}) }
'
real 0m0.048s
user 0m0.032s
sys 0m0.016s
jupiter:~/JAVA/swf-converter-conversion-node$ time python -c 'import itertools
def foo( *args, **kwargs):
kwargs
for _ in itertools.repeat(None, 10000):
foo(1,2,3, a=1, b=2)
'
real 0m0.019s
user 0m0.012s
sys 0m0.008s
jupiter:~/JAVA/swf-converter-conversion-node$ time perl6 -e '
sub foo(*@args, *%kwargs) {
%kwargs
}
for 1..100000 { foo(1,2,3,a=> 1, b => 2) }
'
real 0m33.831s
user 0m33.295s
sys 0m0.504s
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment