際際滷

際際滷Share a Scribd company logo
Rationalを
恷m晒してみた
般戮燭世
Tadashi Saito
2 topics
 How to optimize
Rational
Let's read CRuby
source code more!
 How to optimize
Rational
Let's read CRuby
source code more!
Rational
Rational
Number
Library
1
2
+
2
3
=?
Can't
express with
Float
Can't
express with
BigDecimal
Rational
1/2r + 2/3r
1/2r + 2/3r
#=> (7/6)
Direct
results
Exists since
Ruby 1.0
Ruby 1.9
Built-in class
Ruby 1.9.2
Internal
representa-
tion of Time
Ruby 2.1
Literal
1/2r
More
important in
recent years
It's not so
fast
rb_funcall()
Ruby-level
method calling
in C extention
Porting speed?
Too lazy to impl
polymorphic in C?
Ruby-level
method calling
still exists
Profile with
prof(1)
rb_funcall()
consumes
big time
Let's substitute
it with only C-
layer calculation
Ruby
Association
grant project
submit
http://www.ruby.or.jp/ja/news/20150803.html
Ruby
Association
grant project
adopted!!1
http://www.ruby.or.jp/ja/news/20151116.html
¢
2015-10-30 Notification of result
¢
2016-1-4 intermediate reports
¢
2016-3-4 final reports
¢
2015-10-30 Notification of result
○ HERE! #ragrant2015
¢
2016-1-4 intermediate reports
¢
2016-3-4 final reports
How long was
faster?
(ongoing)
0.000
0.500
1.000
1.500
2.000
2.500
3.000
3.500
4.000
+ fixnum + bignum - fixnum - bignum
0.000
0.500
1.000
1.500
2.000
2.500
3.000
3.500
4.000
x 3
Matz
"Ruby 3x3"
Rational (only)
3.0!!1
Currently
finished only
four arithmetic
operations
I will do my
best also
rest
github.com/tadd/ruby/commits/ragrant2015development
 How to optimize
Rational
Let's read CRuby
source code more!
I was reading
somehow
from the
usual
I don't have
enough
expertise
rb_funcall()
^It's
different from
others ̄
Read source
code somehow
from the usual
Ruby Hacking
Guide
http://i.loveruby.net/ja/rhg/book/
is little
difficult
Built-in
class
libraries
Clear purpose
Independent
Could write in
Ruby
Low cost to
learn
compar.c
230 lines
6 methods
50 commits in
17 years
After
troubled:
doc/extension.ja.rdoc
Only for
extension
libraries?
Ruby
internal uses
same API too
You'll be
able to read
it somehow
Find your
interest points
based on their
file names
Then you'll
find
contributable
points
 How to optimize
Rational
Let's read CRuby
source code more!
Another three
months, I'll try
to optimize
Rational
github.com/tadd/ruby/commits/ragrant2015development

More Related Content

檎温岳庄看稼温鉛を恷癖晒してみた