News for hackers. Stuff that matters.
Re:Coloring in R's Blind Spot by j7ake on Thursday May 11, 2023 @03:04AM (#35898750)
R is hard to parallelise compared to python?

lapply(list, DoSomething)

To parallelise to 16 cores , rewrite as

mclapply(list, DoSomething, mc.cores = 16)

What’s the equivalent in python ?

Re:Coloring in R's Blind Spot by powersnail on Thursday May 11, 2023 @03:29AM (#35898947)
Probably something like:

    with multiprocessing.Pool(core_count) as p:    
        p.map(do_something, list)
Re:Coloring in R's Blind Spot by j7ake on Thursday May 11, 2023 @04:32AM (#35899415)
The parallel code structure looks very different from the standard for loops in python.

So there is a lot of rewriting to get things to work on parallel in python compared to R.

In R you just replace lapply with mclapply.

Re:Coloring in R's Blind Spot by qfwfq_ on Thursday May 11, 2023 @05:07AM (#35899662)
But, many R tools are already vectorised, so your shift from lapply() to mclapply() is about as fair a comparison as claiming it's "just" a shift from python's builtin map() to pool.map(). Anybody can play this game, and it's not helpful. I've been using+teaching R now for nearly seven years and the number of times I've used lapply can be counted on one hand.

> just

https://justsimply.dev/

Re:Coloring in R's Blind Spot by Bootvis on Thursday May 11, 2023 @06:35AM (#35900256)
I use sapply all the time to transform data all the time. It tends to be less code (no counter, no output initialisation ) and easier to follow if that style is familiar.
Re:Coloring in R's Blind Spot by j7ake on Thursday May 11, 2023 @07:47AM (#35900810)
I am curious now, what do you use instead of lapply (or other *apply variants)?
Re:Coloring in R's Blind Spot by nequo on Thursday May 11, 2023 @08:48AM (#35901273)
There is also this in the futureverse if you like for loop style code more:

  library(doFuture)
  plan(multisession)

  y <- foreach(x = 1:4, y = 1:10) %dofuture% {
    z <- x + y
    slow_sqrt(z)
  }
https://dofuture.futureverse.org/
Re:Coloring in R's Blind Spot by Dylan16807 on Thursday May 11, 2023 @04:12PM (#35907764)
> just

This isn't documentation or a guide or helping someone.

It's a friendly competition between languages so it gets to use the perspective of someone that's familiar with things.

Re:Coloring in R's Blind Spot by lozenge on Thursday May 11, 2023 @04:53AM (#35899548)
Serialisation/deserialisation code will bite you unless you are very careful.
Re:Coloring in R's Blind Spot by mellavora on Thursday May 11, 2023 @09:32AM (#35901766)
so, only twice as much code!