cafebabe python macosx easter egg?

Chris Rebert clp2 at
Mon Feb 11 07:49:51 CET 2013

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

~ $ # Huh. Let's google... :
"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: : "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.) :
"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."


"OS X ABI Mach-O File Format Reference":
struct fat_header
    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.

Chris R.

More information about the Python-list mailing list