Giter Club home page Giter Club logo

Comments (3)

traversc avatar traversc commented on May 29, 2024 2

Hi @kendonB , the issue is not environment, but junk <- 1:1e+08 being an ALT-REP, which is a special type of object. Let me explain, but first try this:

normal_lm <- function(){
  set.seed(1); junk <- runif(1e7) # <---- change from your original code
  lm(Sepal.Length ~ Sepal.Width, data = iris)
}

normal_ggplot <- function(){
  set.seed(1); junk <- runif(1e7)
  ggplot2::ggplot()
}

clean_lm <- function () {
  set.seed(1); junk <- runif(1e7) 
  # Run the lm in its own environment
  env <- new.env(parent = globalenv())
  env$subset <- subset
  with(env, lm(Sepal.Length ~ Sepal.Width, data = iris))
}

save_size_qs(normal_lm())
#> [1] 41807225
save_size_rds(normal_lm())
#> [1] 53264446

You can see that for other types of objects, the compressed sizes are similar. In R 3.6, rds uses a new format that serializes ALT-REP objects in a different way. Effectively, rds only saves the 1 and 1e8 in 1:1e8.

I could do this with qs, but it'll take some work and I don't view this as a high priority, since the compression of 1:1e8 is already quite efficient. 1:1e8 is ~400 Mb expanded in memeory, and qs compresses that down to 800 Kb.

In general, an object like 1:1e8 is also not something I think is worth serializing since it's really a number series and not data.

from qs.

kendonB avatar kendonB commented on May 29, 2024

@wlandau fyi

from qs.

kendonB avatar kendonB commented on May 29, 2024

Possibly related: #21

from qs.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.