Upgrade to Pro — share decks privately, control downloads, hide ads and more …

call Ruby methods from Python - An introduction of rb_call

call Ruby methods from Python - An introduction of rb_call

Yohsuke Murase

January 17, 2017
Tweet

More Decks by Yohsuke Murase

Other Decks in Programming

Transcript

  1. About Me • ଜ੉༸հ • twitter : @yohm13 • github:

    yohm • ৬ۀ : ݚڀऀ • ౷ܭ෺ཧ • agent simulation • Ruby, C++ • ࠷ۙPython࢝Ί·ͨ͠
  2. “where”, {“price”: 1000} ΦϒδΣΫτID RubyObject Mongoid::Criteria instance Python Ruby object

    id, “asc”, “author” ΦϒδΣΫτID RubyObject Mongoid::Criteria instance Python Ruby Mongoid::Criteria instance RubyObject
  3. PythonͱRubyͷରԠؔ܎ __str__ __repr__ __eq__ __dir__ __iter__ __len__ __getattr__ __next__ to_s

    inspect == public_methods each size method_missing next PythonͷRubyObjectΫϥεʹ͜ΕΒͷϝιουΛఆٛ͢Ε͹ ͍͍ͩͨಈ༷͘ʹͳΔ
  4. ଞʹ΋ • MessagePackͷextension type Λ࢖͏ • ࢀরͷ਺Λ਺͑ͯϝϞϦϦʔΫ͠ͳ͍Α͏ʹ͢Δ • generatorରԠ ࣮࣭Python

    130ߦ, Ruby 80ߦͷඇৗʹখ͞ͳϥΠϒϥϦʹ Python,Rubyͱ΋ʹॊೈͰɺޓ͍ʹࣅͨݴޠ pipͳͲͰ؆୯ʹར༻Ͱ͖Δ༷ʹ͢Δͷ͕ࠓޙͷ՝୊