3 ms·
This is also possible to a degree in Python, though you only get the bytecode: >>> def f(x): ... return x * x ... >>> import dis >>> pr
by kisielk 13y ago
This is also possible to a degree in Python, though you only get the bytecode:
>>> def f(x):
... return x * x
...
>>> import dis
>>> print dis.dis(f)
2 0 LOAD_FAST 0 (x)
3 LOAD_FAST 0 (x)
6 BINARY_MULTIPLY
7 RETURN_VALUE
- sitkack 13y agoAnd the bytecode is just calling polymorphic methods. All the real work is done in the object implementations of type(x). I was very bummed years ago to realize how shallow the bytecode representation in Python is. There is no sub-terpreter, just C.
- steveklabnik 13y agoYou can get the bytecode in Ruby too: http://www.ruby-doc.org/core-2.1.0/RubyVM/InstructionSequence.html http://www.ruby-doc.org/core-2.1.0/RubyVM/InstructionSequenc...