Project

General

Profile

Actions

Feature #16827

closed

C API for writing custom random number generator that can be used as Random objects

Added by mrkn (Kenta Murata) about 1 year ago. Updated 5 months ago.

Status:
Closed
Priority:
Normal
Target version:
-
[ruby-core:98124]

Description

I want to write custom random number generators (RNGs) that can be used as an alternative to a Random object.
Now custom RNGs with #rand method can be used for that purpose, but there is the method call overhead in the current implementation because #rand method is called through rb_funcallv_public.
I want C API for writing RNGs because all of the random number generator algorithms I want to write are originally written in C.

Nobu already created a pull-request for such purpose.

Updated by matz (Yukihiro Matsumoto) 12 months ago

Sounds OK. Go ahead.

Matz.

Updated by Eregon (Benoit Daloze) 12 months ago

IMHO it's not nice to replace a nice Ruby-level API by a C API one.
Is there a benchmark of how much is it slower with rb_funcallv_public?

Also, will it still work when passing a custom object understanding rand?
If so, there are two ways to dispatch, doesn't seem nice either API-wise.

Updated by mrkn (Kenta Murata) 5 months ago

  • Status changed from Open to Closed

Closed by af5e87ab218c5f4e34c6cdb54ae119a7f0f9033f

Actions

Also available in: Atom PDF