Last active
August 16, 2019 12:05
-
-
Save coolbutuseless/01492f310863b0ff27948108ad15a829 to your computer and use it in GitHub Desktop.
I came here for an argument.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | |
# Simple demo of a 10 argument function | |
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | |
nargs <- 10 | |
f <- function() {} | |
fargs <- as.pairlist(setNames(rep(1, nargs), paste0('v', seq(nargs)))) | |
formals(f) <- fargs | |
f | |
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | |
# Simple demo of a 1 million argument function | |
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | |
nargs <- 1e6 | |
f <- function() {'hello'} | |
fargs <- as.pairlist(setNames(rep(1, nargs), paste0('v', seq(nargs)))) | |
formals(f) <- fargs | |
f() | |
# 160 MB function! | |
lobstr::obj_size(f) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment