Displaying 20 results from an estimated 9000 matches similar to: "we need an exists/get hybrid"
2014 Dec 03
2
we need an exists/get hybrid
Thanks Winston! I'm amazed that "[[" beats calling the .Internal
directly. I guess the difference between .Primitive vs. .Internal is
pretty significant for things on this time scale.
NULL meaning NULL and NULL meaning undefined would lead to the same path
for much of my code. I'll be swapping out many exists and get calls later
today. Thanks!
I do still think it would be
2015 Jan 09
2
RFC: getifexists() {was [Bug 16065] "exists" ...}
>>>>> Martin Maechler <maechler at stat.math.ethz.ch>
>>>>> on Fri, 9 Jan 2015 14:00:38 +0100 writes:
>>>>> Michael Lawrence <lawrence.michael at gene.com>
>>>>> on Thu, 8 Jan 2015 14:02:26 -0800 writes:
>> On Thu, Jan 8, 2015 at 11:57 AM, <luke-tierney at uiowa.edu> wrote:
>>> On Thu, 8
2014 Dec 04
0
we need an exists/get hybrid
All,
So that suggests that .GlobalEnv[["X"]] is more efficient than get("X",
pos=1L). What about .GlobalEnv[["X"]] <- value, compared to assign("X",
value)?
Dave
On Wed, Dec 3, 2014 at 3:30 PM, Peter Haverty <haverty.peter at gene.com>
wrote:
> Thanks Winston! I'm amazed that "[[" beats calling the .Internal
> directly. I
2014 Dec 03
0
we need an exists/get hybrid
I've looked at related speed issues in the past, and have a couple
related points to add. (I've put the info below at
http://rpubs.com/wch/46428.)
There?s a significant amount of overhead just from calling the R
function get(). This is true even when you skip the pos argument and
provide envir. For example, if you call get(), it takes much more time
than .Internal(get()), which is what
2015 Jan 21
2
reducing redundant work in methods package
Doing it like this:
genericForPrimitive <- function(f, where = topenv(parent.frame()), mustFind
= TRUE) {
ans = .BasicFunsList[[f]]
## this element may not exist (yet, during loading), dom't test null
if(mustFind && identical(ans, FALSE))
stop(gettextf("methods may not be defined for primitive function %s
in this version of R",
2013 Aug 18
1
How does R_UnboundValue and removing variables work?
Reading "R Internals" made me believe that R_UnboundValue was a placeholder
that would be skipped over in variable lookup. viz. the section of R
Internals "Hash tables" says "items are not actually deleted but have their
value set to R_UnboundValue.", which seems to align with what I read in
envir.c.
So, I reasoned, if I have a function that returns R_UnboundValue,
2019 Aug 15
1
Rf_defineVar(symbol, R_UnboundValue, environment) questions
While poking around the C++ code in the dplyr package I ran across the idiom
Rf_defineVar(symbol, R_UnboundValue, environment)
to [sort of] remove 'symbol' from 'environment'
Using it makes the R-level functions objects(), exists(), and get()
somewhat inconsistent and I was wondering if that was intended. E.g., use
SHLIB to make something from the following C code that
2015 Jan 08
4
RFC: getifexists() {was [Bug 16065] "exists" ...}
If we do add an argument to get(), then it should be named consistently
with the ifnotfound argument of mget(). As mentioned, the possibility of a
NULL value is problematic. One solution is a sentinel value that indicates
an unbound value (like R_UnboundValue).
But another idea (and one pretty similar to John's) is to follow the SYMSXP
design at the C level, where there is a structure that
2015 Jan 21
2
reducing redundant work in methods package
Hi all,
The function call series genericForPrimitive -> .findBasicFuns -> .findAll
happens 4400 times while the GenomicRanges package is loading. Each time
.findAll follows a chain of environments to determine that the methods
namespace is the only one that holds a variable called .BasicFunsList. This
accounts for ~10% of package loading time. I'm sure there is some history
to that
2008 May 24
1
value returned by findFun when the name cannot be found.
Dear list,
I have been using "findVar" (defined in src/main/envir.c) happily and
would like to use
"findFun".
However I have trouble when the name searched cannot be found: while
"findVar" returns R_UnboundValue,
"findFun" does not (the 4 last lines of "findFun" are copied below).
error(_("could not find function
2015 Jan 27
2
names function for environments?
I think ls(, sort=FALSE) would be more explicit and thus clearer. There is
much precedent for having arguments that request less work to be done e.g.
unlist(use.names=FALSE). Yes, the extra typing is a bit painful, but there
is no intuitive reason why names() would be unsorted, while ls() would be
sorted. While it is tempting to use an existing function for this, the word
"names" is
2015 Jan 22
3
speedbump in library
Hi all,
Profiling turned up a bit of a speedbump in the library function. I
submitted a patch to the R bug tracker as bug 16168 and I've also
included it below. The alternate code is simpler and easier to
read/maintain, I believe. Any thoughts on other ways to write this?
Index: src/library/base/R/library.R
===================================================================
---
2015 Jan 27
2
names function for environments?
Since the contract of ls() is to sort, there is nothing wrong with
programmers depending on it. And there are many functions that could be
made 60X faster, but is it worth it? But I did notice that
as.list.environment has a sorted=FALSE argument already, so I guess
identical(names(x), names(as.list(x))) could be made to be TRUE, assuming
the order is at least persistent, if undefined, so that is a
2015 Jan 08
3
setequal: better readability, reduced memory footprint, and minor speedup
How about unique them both and compare the lengths? It's less work,
especially allocation.
Pete
____________________
Peter M. Haverty, Ph.D.
Genentech, Inc.
phaverty at gene.com
On Thu, Jan 8, 2015 at 1:30 PM, peter dalgaard <pdalgd at gmail.com> wrote:
> If you look at the definition of %in%, you'll find that it is implemented
> using match, so if we did as you suggest,
2015 Jan 22
5
:: and ::: as .Primitives?
Hi all,
When S4 methods are defined on base function (say, "match"), the
function becomes a method with the body "base::match(x,y)". A call to
such a function often spends more time doing "::" than in the function
itself. I always assumed that "::" was a very low-level thing, but it
turns out to be a plain old function defined in base/R/namespace.R.
What
2015 Jan 08
2
RFC: getifexists() {was [Bug 16065] "exists" ...}
On Thu, Jan 8, 2015 at 11:57 AM, <luke-tierney at uiowa.edu> wrote:
> On Thu, 8 Jan 2015, Michael Lawrence wrote:
>
> If we do add an argument to get(), then it should be named consistently
>> with the ifnotfound argument of mget(). As mentioned, the possibility of a
>> NULL value is problematic. One solution is a sentinel value that indicates
>> an unbound value
2015 Jan 25
2
names function for environments?
Hi all,
The "ls" function wears two hats. It allows users to inspect an
environment interactively and also serves deeper in code as the
accessor for an environment's names/keys. I propose that we separate
these two conflicting goals, keeping ls for interactive use and adding
names for a quick listing of the hash keys. This involves adding two
lines to do_names in attrib.c.
The
2015 Jan 22
5
:: and ::: as .Primitives?
On Thu, Jan 22, 2015 at 11:44 AM, <luke-tierney at uiowa.edu> wrote:
>
> For default methods there ought to be a way to create those so the
> default method is computed at creation or load time and stored in an
> environment.
We had considered that, but we thought the definition of the function
would be easier to interpret if it explicitly specified the namespace,
instead of
2015 Jan 22
1
:: and ::: as .Primitives?
On Thu, Jan 22, 2015 at 11:44 AM, <luke-tierney at uiowa.edu> wrote:
> I'm not convinced that how to make :: faster is the right question. If
> you are finding foo::bar being called often enough to matter to your
> overall performance then to me the question is: why are you calling
> foo::bar more than once? Making :: a bit faster by making it a
> primitive will remove
2015 Jan 23
1
:: and ::: as .Primitives?
Hi,
On 01/23/2015 07:01 AM, luke-tierney at uiowa.edu wrote:
> On Thu, 22 Jan 2015, Michael Lawrence wrote:
>
>> On Thu, Jan 22, 2015 at 11:44 AM, <luke-tierney at uiowa.edu> wrote:
>>>
>>> For default methods there ought to be a way to create those so the
>>> default method is computed at creation or load time and stored in an
>>>