Re: cafebabe python macosx easter egg?

Discussion in 'Python' started by Chris Rebert, Feb 11, 2013.

  1. Chris Rebert

    Chris Rebert Guest

    On Sun, Feb 10, 2013 at 10:10 PM, Rodrick Brown <> wrote:
    > Subject: cafebabe python macosx easter egg?
    >
    > $ hexdump -n4 -C $(which python) | awk '{print $2 $3 $4 $5 }'

    cafebabe

    ~ $ # Huh. Let's google...
    http://en.wikipedia.org/wiki/Hexspeak :
    "0xCAFEBABE ("cafe babe") is used by Mach-O to identify Universal
    object files, and by the Java programming language to identify Java
    bytecode class files."


    Some background:

    http://en.wikipedia.org/wiki/Mach-O : "Mach-O […] is a file format for
    executables […] used by most systems based on the Mach kernel" (OS X's
    kernel is based on the Mach kernel.)

    http://en.wikipedia.org/wiki/Universal_binary :
    "A universal binary is, in Apple parlance, an executable file or
    application bundle that runs natively on either PowerPC or […] Intel
    64-based Macintosh computers; it is an implementation of the concept
    more generally known as a fat binary."


    Confirmation:

    "OS X ABI Mach-O File Format Reference":
    https://developer.apple.com/library...ceptual/MachORuntime/Reference/reference.html
    :
    struct fat_header
    [...]
    Fields:
    magic
    An integer containing the value 0xCAFEBABE in big-endian byte order format.


    So, there you have it. Mach-O and Java bytecode just happen to use the
    same magic number. Coincidence.

    Cheers,
    Chris R.
     
    Chris Rebert, Feb 11, 2013
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Catherine
    Replies:
    2
    Views:
    347
    John Nagle
    Oct 8, 2007
  2. Terry Michaels

    Trollop: Easter Egg Switches?

    Terry Michaels, Sep 25, 2010, in forum: Ruby
    Replies:
    0
    Views:
    101
    Terry Michaels
    Sep 25, 2010
  3. Alexis Nikichine

    Easter egg (and rant) of the day

    Alexis Nikichine, Oct 20, 2004, in forum: Javascript
    Replies:
    1
    Views:
    79
    Martin Honnen
    Oct 20, 2004
  4. Rodrick Brown

    cafebabe python macosx easter egg?

    Rodrick Brown, Feb 11, 2013, in forum: Python
    Replies:
    0
    Views:
    110
    Rodrick Brown
    Feb 11, 2013
  5. Chris Angelico

    Re: cafebabe python macosx easter egg?

    Chris Angelico, Feb 11, 2013, in forum: Python
    Replies:
    0
    Views:
    140
    Chris Angelico
    Feb 11, 2013
Loading...

Share This Page