Open-Awesome
CategoriesAlternativesStacksSelf-HostedExplore
Open-Awesome

© 2026 Open-Awesome. Curated for the developer elite.

TermsPrivacyAboutGitHubRSS
  1. Home
  2. Ruby
  3. PyCall

PyCall

MITCv1.5.2

A Ruby library that enables direct calling of Python functions and modules with automatic type conversion.

GitHubGitHub
1.1k stars88 forks0 contributors

What is PyCall?

PyCall is a Ruby gem that enables direct calling of Python functions and modules from Ruby code. It solves the problem of Ruby developers needing to access Python's vast ecosystem of libraries (like NumPy, pandas, or machine learning frameworks) by providing seamless interoperability with automatic type conversion between the two languages.

Target Audience

Ruby developers who need to integrate Python libraries for data science, machine learning, scientific computing, or any task where Python's ecosystem offers superior tools.

Value Proposition

Developers choose PyCall because it provides the most straightforward and Ruby-idiomatic way to call Python code, with automatic type conversion, support for keyword arguments, and intuitive mapping of Python constructs to Ruby syntax, without requiring complex bindings or external processes.

Overview

Calling Python functions from the Ruby language

Use Cases

Best For

  • Using Python's data science libraries (like pandas or NumPy) within a Ruby on Rails application
  • Integrating machine learning models written in Python (e.g., TensorFlow, scikit-learn) into Ruby services
  • Accessing specialized Python-only libraries from Ruby without rewriting functionality
  • Building hybrid applications that leverage both Ruby's web ecosystem and Python's scientific computing strengths
  • Prototyping or scripting that requires quick access to Python modules from a Ruby environment
  • Educational purposes to compare or bridge concepts between Ruby and Python

Not Ideal For

  • Applications requiring robust multi-threading with concurrent Ruby and Python executions
  • Environments where Python shared libraries are not available or difficult to install
  • Projects that need to minimize overhead in cross-language calls

Pros & Cons

Pros

Direct Python Import

Allows importing any Python module as a Ruby module, making functions callable with minimal syntax, as shown in the README example with math.sin.

Automatic Type Conversion

Handles conversions for basic types like numbers, strings, arrays, and hashes without manual intervention, simplifying cross-language data passing.

Intuitive Syntax Mapping

Maps Python constructors to .new and callables to .(), with keyword arguments using Ruby hash syntax, making Python code feel natural in Ruby.

GVL Control for Performance

Provides PyCall.without_gvl to release Ruby's GVL during long Python calls, improving concurrency in blocking operations, as documented in the usage section.

Cons

No Multi-threading Support

Officially does not support multi-threaded use, as admitted in the README, limiting scalability in concurrent applications.

Complex pyenv Setup

Requires rebuilding Python with --enable-shared for pyenv users, an extra non-default step that complicates installation.

Limited Attribute Access

Callable attributes cannot be accessed directly; requires using PyCall.getattr as a workaround, adding syntactic friction.

Frequently Asked Questions

Quick Stats

Stars1,113
Forks88
Contributors0
Open Issues44
Last commit19 days ago
CreatedSince 2016

Tags

#scientific-computing#data-science#ruby-gem#rubyml#python#language-interoperability#foreign-function-interface#ruby#type-conversion

Built With

R
Ruby

Included in

Ruby14.1k
Auto-fetched 6 hours ago

Related Projects

decisiontreedecisiontree

ID3-based implementation of the ML Decision Tree algorithm

Stars1,481
Forks130
Last commit7 years ago
darudaru

Data Analysis in RUby

Stars1,059
Forks140
Last commit2 years ago
SciRubySciRuby

Tools for scientific computation in Ruby

Stars1,001
Forks79
Last commit6 years ago
iRubyiRuby

Official gem repository: Ruby kernel for Jupyter/IPython Notebook

Stars925
Forks35
Last commit4 months ago
Community-curated · Updated weekly · 100% open source

Found a gem we're missing?

Open-Awesome is built by the community, for the community. Submit a project, suggest an awesome list, or help improve the catalog on GitHub.

Submit a projectStar on GitHub