develooper Front page | perl.perl6.users | Postings from June 2020

Re: Help converting CArray[uint8] to Blob

Thread Previous | Thread Next
From:
David Santiago
Date:
June 17, 2020 08:02
Subject:
Re: Help converting CArray[uint8] to Blob
Message ID:
CAO5X0j52TTe4fmOPqLPjEegG19VwrejqP-z6mJN82bqhJmF_7A@mail.gmail.com
Hi!


> $ed.data.head($ed.data_size)

Unfortunately, i get the error "Error
X::AdHoc+{X::Await::Died}+{X::React::Died}: Don't know how many
elements a C array returned from a library"

> > my uint8 @data = $ed.data[0..$ed.data_size-1].Array;
> > my Blob $bindata = Blob[uint8].new(@data);
>
> Afaict that's a total of five HLL element-by-element copies.
>
> I would expect this to work and be at least as fast and possibly a lot faster:
>
> my Blob $bindata .= new: $ed.data;


Because of the error above, i have to do:

my Blob $bindata .= new: $ed.data[^$ed.data_size];


which takes slightly more than 1 sec:
Bindata in 1.1679568

Btw, the size of the $ed.data_size is 750K.

Regards.
David Santiago

Ralph Mellor <ralphdjmellor@gmail.com> escreveu no dia terça,
16/06/2020 à(s) 23:08:
>
> > my Data $ed = await $yenc_promise;
>
> The promise must initialize each element of the CArray[uint]. It looks
> pretty quick; I'm guessing it's low-level code doing that.
>
> > my uint8 @data = $ed.data[0..$ed.data_size-1].Array;
> > my Blob $bindata = Blob[uint8].new(@data);
>
> Afaict that's a total of five HLL element-by-element copies.
>
> I would expect this to work and be at least as fast and possibly a lot faster:
>
> my Blob $bindata .= new: $ed.data;
>
> hth

Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About