-
Notifications
You must be signed in to change notification settings - Fork 88
C API to create BigDecimal objects #506
Copy link
Copy link
Open
Description
BigDecimal is used by various database clients, as well as various serialization libraries. Many of those are implemented in C, and for them creating BigDecimal objects is an important bottleneck.
For example, here's the relevant code in the Trilogy MySQL client gem: https://github.com/trilogy-libraries/trilogy/blob/7fcfe8c1c79208c6c56439d1d29c7dc591442c53/contrib/ruby/ext/trilogy-ruby/cast.c#L236-L241
It needs to:
- Allocate a Ruby String and cpy the bytes into it.
- Use
rb_funcallto invokeBigDecimal().
The string allocation isn't too bad, but having to use method dispatch is quite costly.
It would be very useful if there was a set of C APIs to efficiently allocate BigDecimal objects:
VALUE BigDecimal_from_str(const char *, size_t len)`Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels