Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@msakai
Created October 30, 2019 02:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save msakai/4deae725a7f065b98706483f1ccb693f to your computer and use it in GitHub Desktop.
Save msakai/4deae725a7f065b98706483f1ccb693f to your computer and use it in GitHub Desktop.
print(0x10000000000000000 is 0x10000000000000000)
#=> True
import dis
b = dis.Bytecode(lambda: 0x10000000000000000 is 0x10000000000000000)
print(b.dis())
#=>
# 4 0 LOAD_CONST 1 (18446744073709551616)
# 2 LOAD_CONST 1 (18446744073709551616)
# 4 COMPARE_OP 8 (is)
# 6 RETURN_VALUE
print(b.info())
#=>
# Name: <lambda>
# Filename: int_object.py
# Argument count: 0
# Kw-only arguments: 0
# Number of locals: 0
# Stack size: 2
# Flags: OPTIMIZED, NEWLOCALS, NOFREE
# Constants:
# 0: None
# 1: 18446744073709551616
p(0x10000000000000000.equal? 0x10000000000000000)
# => false
puts RubyVM::InstructionSequence.compile("0x10000000000000000.equal? 0x10000000000000000").disasm
# =>
# == disasm: #<ISeq:<compiled>@<compiled>:1 (1,0)-(1,46)>=================
# 0000 putobject 18446744073709551616 ( 1)[Li]
# 0002 putobject 18446744073709551616
# 0004 opt_send_without_block <callinfo!mid:equal?, argc:1, ARGS_SIMPLE>, <callcache>
# 0007 leave
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment