Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Does Ruby have an equivalent to the __pycache__ folder in Python?

In Python, after you run a program, there are caches saved in the folders named __pycache__. For futher explanation of the functionality of these folders, please see this question. Does Ruby have an equivalent of this? If not, why?

like image 406
Seanny123 Avatar asked Mar 31 '26 21:03

Seanny123


1 Answers

Ruby doesn't haven an equivalent. It just wouldn't make sense: Ruby is a programming language. A programming language is an abstract mathematical concept, a specification. Putting such detailed things as the name of the directory of the byte code cache in a language would be way too restrictive: what if somebody wants to implement Ruby on a platform which doesn't have files? What if someone wants to implement Ruby on a platform where underscores are illegal in directory names? What if someone wants to implement Ruby with an interpreter instead of a compiler?

There are, however, some Ruby implementations which do compile to byte code. YARV and Rubinius are two examples of those. YARV only compiles in memory, whereas Rubinius caches the compiled byte code on disk. In fact, it must have the ability to save and read the compiled byte code because the compiler itself is written in Ruby, and otherwise it would have to compile itself in order to be able to compile any code, but in order to compile itself it would first have to compile itself and in order to that it would first have to …

But that is a private internal implementation detail of Rubinius. It is not part of Ruby nor should it be.

like image 50
Jörg W Mittag Avatar answered Apr 03 '26 16:04

Jörg W Mittag