मैं एक पैकेज बनाए रखता हूं जो बार-बार कॉल करने पर निर्भर करता है deparse(control = c("keepNA", "keepInteger"))। controlहमेशा समान होता है, और अभिव्यक्ति भिन्न होती है। deparse()लगता है कि विकल्पों के एक ही सेट की बार-बार व्याख्या करने में बहुत समय व्यतीत होता है .deparseOpts()।
microbenchmark::microbenchmark(
a = deparse(identity, control = c("keepNA", "keepInteger")),
b = .deparseOpts(c("keepNA", "keepInteger"))
)
# Unit: microseconds
# expr min lq mean median uq max neval
# a 7.2 7.4 8.020 7.5 7.6 55.1 100
# b 3.0 3.2 3.387 3.4 3.5 6.0 100
कुछ प्रणालियों पर, निरर्थक .deparseOpts()कॉल वास्तव में deparse()( लौ का ग्राफ ) के रनटाइम के बहुमत को ले जाते हैं ।
मैं वास्तव में सिर्फ .deparseOpts()एक बार कॉल करना चाहूंगा और फिर संख्यात्मक कोड को आपूर्ति करूंगा deparse(), लेकिन यह .Internal()सी फोन को सीधे कॉल या इनवॉइस किए बिना असंभव प्रतीत होता है , जिनमें से कोई भी पैकेज विकास के नजरिए से इष्टतम नहीं है।
deparse
# function (expr, width.cutoff = 60L, backtick = mode(expr) %in%
# c("call", "expression", "(", "function"),
# control = c("keepNA", "keepInteger", "niceNames",
# "showAttributes"), nlines = -1L)
# .Internal(deparse(expr, width.cutoff, backtick, .deparseOpts(control),
# nlines))
# <bytecode: 0x0000000006ac27b8>
# <environment: namespace:base>
क्या कोई सुविधाजनक समाधान है?