Comments (3)
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.
@wlandau fyi
from qs.
Possibly related: #21
from qs.
Related Issues (20)
- Error in qdeserialize(x) : Endian of system doesn't match file endian HOT 15
- Apple Silicon ? HOT 1
- Suggestion : default parameter nthread HOT 2
- can't install 'qs' package on remote server CentOS Linux 7 (Core) HOT 1
- replacement of save.image ? HOT 2
- zstd decompression error - qread() HOT 2
- Documentation and examples, especially for qsave_ptr HOT 1
- Unexpected behavior when loading .qs file HOT 2
- Extra memory usage when loading an object twice HOT 2
- Slowly when using multiple threads HOT 1
- ALTREP serialization and deserialization methods are ignored HOT 20
- Rocky 8 Linux: ld: cannot find -latomic HOT 17
- Saving ggplot object results in indefinitely growing file HOT 3
- qs apparently slower than rds when saving nested lists HOT 2
- DESCRIPTION file broken? HOT 6
- read part of a qs file into memory HOT 1
- Deserialization arbitrary code execution attack HOT 5
- qsave() bad binding access HOT 5
- qread() cannot locate file on cloud? HOT 4
- segfault: RApiSerialize update requires rebuilding/reinstalling qs from source HOT 6
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from qs.