From: "larskanis (Lars Kanis) via ruby-core" Date: 2026-03-26T11:25:48+00:00 Subject: [ruby-core:125137] [Ruby Feature#21853] Make Embedded TypedData a public API Issue #21853 has been updated by larskanis (Lars Kanis). I found the original PR which added `RUBY_TYPED_EMBEDDABLE` very readable and expressive: https://github.com/ruby/ruby/pull/7440/changes It allowed me understand and use the feature in swig and fxruby without any docs. With the latest changes in https://github.com/ruby/ruby/pull/16455 , https://github.com/ruby/ruby/pull/16509 , https://github.com/ruby/ruby/pull/16518 I think it is easy and clear how to use it safely. ---------------------------------------- Feature #21853: Make Embedded TypedData a public API https://bugs.ruby-lang.org/issues/21853#change-116867 * Author: byroot (Jean Boussier) * Status: Closed ---------------------------------------- As part of Ruby 3.3, we added a private `RUBY_TYPED_EMBEDDABLE` flag to the `TypedData` API to allow `TypedData` to use variable width allocation. Technically, we inadvertently exposed that flag in public headers so third party extensions can make use of it, but it's not considered public API as it's not documented, so it would be a poor decision. This API has both memory and speed benefits as it allow to avoid some `malloc/free` churn, reduce pointer chasing, etc. For instance, when we converted `Time` to be embedded, it improved allocation performance by 30% and also reduced memory usage by 20%: https://github.com/ruby/ruby/commit/aa6642de630cfc10063154d84e45a7bff30e9103 I believe numerous third party native extensions could benefit from it (I would certainly make use of it in `ruby/json`), now that we used it internally for several years, I'd like to work on making it a public API for Ruby 4.1 -- https://bugs.ruby-lang.org/ ______________________________________________ ruby-core mailing list -- ruby-core@ml.ruby-lang.org To unsubscribe send an email to ruby-core-leave@ml.ruby-lang.org ruby-core info -- https://ml.ruby-lang.org/mailman3/lists/ruby-core.ml.ruby-lang.org/