Re: [R-pkg-devel] Fast Matrix Serialization in R?

2024-05-10 Thread Ivan Krylov via R-package-devel
On Fri, 10 May 2024 15:12:17 +1200 Simon Urbanek wrote: > I wonder if it may be worth doing something a bit smarter and tag > officially a "reverse XDR" format instead - that way it would be > well-defined and could be made the default. Do you mean changing R so that when reading a "B\n" seriali

Re: [R-pkg-devel] Fast Matrix Serialization in R?

2024-05-09 Thread Simon Urbanek
> On 10/05/2024, at 12:31 PM, Henrik Bengtsson > wrote: > > On Thu, May 9, 2024 at 3:46 PM Simon Urbanek > wrote: >> >> FWIW serialize() is binary so there is no conversion to text: >> >>> serialize(1:10+0L, NULL) >> [1] 58 0a 00 00 00 03 00 04 02 00 00 03 05 00 00 00 00 05 55 54 46 2d 38

Re: [R-pkg-devel] Fast Matrix Serialization in R?

2024-05-09 Thread Henrik Bengtsson
On Thu, May 9, 2024 at 3:46 PM Simon Urbanek wrote: > > > > > On 9/05/2024, at 11:58 PM, Vladimir Dergachev > > wrote: > > > > > > > > On Thu, 9 May 2024, Sameh Abdulah wrote: > > > >> Hi, > >> > >> I need to serialize and save a 20K x 20K matrix as a binary file. This > >> process is significa

Re: [R-pkg-devel] Fast Matrix Serialization in R?

2024-05-09 Thread Simon Urbanek
> On 9/05/2024, at 11:58 PM, Vladimir Dergachev wrote: > > > > On Thu, 9 May 2024, Sameh Abdulah wrote: > >> Hi, >> >> I need to serialize and save a 20K x 20K matrix as a binary file. This >> process is significantly slower in R compared to Python (4X slower). >> >> I'm not sure about t

Re: [R-pkg-devel] Fast Matrix Serialization in R?

2024-05-09 Thread Vladimir Dergachev
On Thu, 9 May 2024, Sameh Abdulah wrote: Hi, I need to serialize and save a 20K x 20K matrix as a binary file. This process is significantly slower in R compared to Python (4X slower). I'm not sure about the best approach to optimize the below code. Is it possible to parallelize the seria

Re: [R-pkg-devel] Fast Matrix Serialization in R?

2024-05-08 Thread Simon Urbanek
Sameh, if it's a matrix, that's easy as you can write it directly which is the fastest possible way without compression - e.g. quick proof of concept: n <- 2^2 A <- matrix(runif(n), ncol = sqrt(n)) ## write (dim + payload) con <- file(description = "matrix_file", open = "wb") system.time({

Re: [R-pkg-devel] Fast Matrix Serialization in R?

2024-05-08 Thread Dirk Eddelbuettel
On 9 May 2024 at 03:20, Sameh Abdulah wrote: | I need to serialize and save a 20K x 20K matrix as a binary file. Hm that is an incomplete specification: _what_ do you want to do with it? Read it back in R? Share it with other languages (like Python) ? I.e. what really is your use case? Also, y

[R-pkg-devel] Fast Matrix Serialization in R?

2024-05-08 Thread Sameh Abdulah
Hi, I need to serialize and save a 20K x 20K matrix as a binary file. This process is significantly slower in R compared to Python (4X slower). I'm not sure about the best approach to optimize the below code. Is it possible to parallelize the serialization function to enhance performance? n