[Rd] object.size vs lobstr::obj_size

Stefan Schreiber @@chre|b @end|ng |rom u@|bert@@c@
Sat Mar 28 06:21:52 CET 2020


Thank you Tomas, Hervé and Hadley for the input. Much appreciated!

Stefan

Stefan Schreiber, PhD, P. Biol.
Director EnviroStats Solutions Inc.
Adjunct Professor, Faculty of Agricultural, Life & Environmental
Sciences, University of Alberta
Phone: 780-221-1838
https://envirostats.ca/



On Fri, 27 Mar 2020 at 16:25, Hervé Pagès <hpages using fredhutch.org> wrote:
>
> On 3/27/20 15:19, Hadley Wickham wrote:
> >
> >
> > On Fri, Mar 27, 2020 at 4:01 PM Hervé Pagès <hpages using fredhutch.org
> > <mailto:hpages using fredhutch.org>> wrote:
> >
> >
> >
> >     On 3/27/20 12:00, Hadley Wickham wrote:
> >      >
> >      >
> >      > On Fri, Mar 27, 2020 at 10:39 AM Hervé Pagès
> >     <hpages using fredhutch.org <mailto:hpages using fredhutch.org>
> >      > <mailto:hpages using fredhutch.org <mailto:hpages using fredhutch.org>>> wrote:
> >      >
> >      >     Hi Tomas,
> >      >
> >      >     On 3/27/20 07:01, Tomas Kalibera wrote:
> >      >      > they provide an over-approximation
> >      >
> >      >     They can also provide an "under-approximation" (to say the
> >     least) e.g.
> >      >     on reference objects where the entire substance of the object is
> >      >     ignored
> >      >     which makes object.size() completely meaningless in that case:
> >      >
> >      >         setRefClass("A", fields=c(stuff="ANY"))
> >      >         object.size(new("A", stuff=raw(0)))      # 680 bytes
> >      >         object.size(new("A", stuff=runif(1e8)))  # 680 bytes
> >      >
> >      >     Why wouldn't object.size() look at the content of environments?
> >      >
> >      >
> >      > As the author, I'm obviously biased, but I do like
> >     lobstr::obj_sizes()
> >      > which allows you to see the additional size occupied by one
> >     object given
> >      > any number of other objects. This is particularly important for
> >      > reference classes since individual objects appear quite large:
> >      >
> >      > A <- setRefClass("A", fields=c(stuff="ANY"))
> >      > lobstr::obj_size(new("A", stuff=raw(0)))
> >      > #> 567,056 B
> >      >
> >      > But the vast majority is shared across all instances of that class:
> >      >
> >      > lobstr::obj_size(A)
> >      > #> 719,232 B
> >      > lobstr::obj_sizes(A, new("A", stuff=raw(0)))
> >      > #> * 719,232 B
> >      > #> *     720 B
> >      > lobstr::obj_sizes(A, new("A", stuff=runif(1e8)))
> >      > #> *     719,232 B
> >      > #> * 800,000,720 B
> >
> >     Nice. Can you clarify the situation with lobstr::obj_size vs
> >     pryr::object_size? I've heard of the latter before and use it sometimes
> >     but never heard of the former before seeing Stefan's post. Then I
> >     checked the authors of both and thought maybe they should talk to each
> >     other ;-)
> >
> >
> > pryr is basically retired :) TBH I don't know why I gave up on it,
> > except lobstr is a cooler name 🤣 That's where all active development is
> > happening. (The underlying code is substantially similar although
> > lobstr includes bug fixes not present in pryr)
>
> Good to know, thanks! Couldn't find any mention of pryr being abandoned
> and superseded by lobster (which definitely sounds more yummy) in pryr's
> README.md or DESCRIPTION file. Would be good to put this somewhere.
>
> H.
>
>
> >
> > Hadley
> > --
> > http://hadley.nz
> > <https://urldefense.proofpoint.com/v2/url?u=http-3A__hadley.nz&d=DwMFaQ&c=eRAMFD45gAfqt84VtBcfhQ&r=BK7q3XeAvimeWdGbWY_wJYbW0WYiZvSXAJJKaaPhzWA&m=YbZWqj-epVToKynrOqXF8TgrxHYKx1pF3q2GrOuJwBQ&s=qCeYCgVDbk_GzadBoAgc3cf81fQfRJXpsf0P5meMhtU&e=>
>
> --
> Hervé Pagès
>
> Program in Computational Biology
> Division of Public Health Sciences
> Fred Hutchinson Cancer Research Center
> 1100 Fairview Ave. N, M1-B514
> P.O. Box 19024
> Seattle, WA 98109-1024
>
> E-mail: hpages using fredhutch.org
> Phone:  (206) 667-5791
> Fax:    (206) 667-1319



More information about the R-devel mailing list