-
Notifications
You must be signed in to change notification settings - Fork 7
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support arbitrary R objects #5
Comments
Hey, I totally agree, this should be supported. I was planning to add this already, but to be honest I don't know the C API well enough yet to implement this. Unfortunately there are also not too many sources except the R documentation. Let me quickly explain my problem. So, as far as I know I need to predefine typedef binomial_heap<int, double> binomial_heap_id; Now suppose I want a heap of > list(a=1, b="a")
$a
[1] 1
$b
[1] "a" If I look at the pryr::inspect(list(a=1, b="a"))
<VECSXP 0x7f90fc23b950>
<REALSXP 0x7f90fc04baf8>
<STRSXP 0x7f90fc04ba98>
<CHARSXP 0x7f90fa814798>
attributes:
<LISTSXP 0x7f90fbcbf440>
tag:
<SYMSXP 0x7f90fb80a940>
car:
<STRSXP 0x7f90fc23b8e0>
[CHARSXP 0x7f90fa814798]
<CHARSXP 0x7f90fb30d3f8>
cdr:
NULL I haven't checked, how I could implement this for different data types. If I can just typedef binomial_heap<int, SEXP> binomial_heap_id; this would be easy. As soon as I have more time, I'll have a look into this. Thanks for the feedback! |
SEXP is just a pointer, you just need to make sure R GC doesn't remove the memory by preserving it. Update: However..
|
Another possibility is to serialize the R objects to raw vectors via |
Oh wow, that's great! Thanks! |
One more alternative, you could also store the R objects in a queue using a pairlist if you think |
I generally prefer to avoid serialization in R because it is usually a performance bottleneck. |
Dear @randy3k, the latest version of the package implements your suggestions. Thanks for the tips and feedback.
Please let me know if I can close this issue. |
I am wondering is there any plan to support arbitrary R objects, eg, lists or environments in the future. The current implementation has somewhat limited the practical usability of the package. Thanks.
The text was updated successfully, but these errors were encountered: