diff --git a/if/reflection_limited.thrift b/if/reflection_limited.thrift
index 7769817..e96416f 100644
--- a/if/reflection_limited.thrift
+++ b/if/reflection_limited.thrift
@@ -15,6 +15,7 @@
 
 cpp_namespace facebook.thrift.reflection.limited
 java_package com.facebook.thrift.reflection.limited
+py_module thrift.reflection.limited
 
 enum TTypeTag {
   T_VOID   = 1,
diff --git a/if/regen.sh b/if/regen.sh
index 03dad02..ed25cc6 100755
--- a/if/regen.sh
+++ b/if/regen.sh
@@ -1,5 +1,6 @@
 #!/bin/sh
 cd "`dirname $0`"
-../compiler/cpp/thrift -cpp reflection_limited.thrift
+../compiler/cpp/thrift -cpp -py reflection_limited.thrift
 cp gen-cpp/reflection_limited_types.h   ../lib/cpp/src/
 cp gen-cpp/reflection_limited_types.cpp ../lib/cpp/src/
+cp -r gen-py/thrift/reflection ../lib/py/src
diff --git a/lib/cpp/src/reflection_limited_types.cpp b/lib/cpp/src/reflection_limited_types.cpp
index d5c6153..c47d982 100644
--- a/lib/cpp/src/reflection_limited_types.cpp
+++ b/lib/cpp/src/reflection_limited_types.cpp
@@ -7,6 +7,9 @@
 
 namespace facebook { namespace thrift { namespace reflection { namespace limited {
 
+char* SimpleType::ascii_fingerprint = "19B5240589E680301A7E32DF3971EFBE";
+char SimpleType::binary_fingerprint[16] = {0x19,0xB5,0x24,0x05,0x89,0xE6,0x80,0x30,0x1A,0x7E,0x32,0xDF,0x39,0x71,0xEF,0xBE};
+
 uint32_t SimpleType::read(facebook::thrift::protocol::TProtocol* iprot) {
 
   uint32_t xfer = 0;
@@ -71,6 +74,9 @@
   return xfer;
 }
 
+char* ContainerType::ascii_fingerprint = "654FA6EFFF8242F4C2A604B970686634";
+char ContainerType::binary_fingerprint[16] = {0x65,0x4F,0xA6,0xEF,0xFF,0x82,0x42,0xF4,0xC2,0xA6,0x04,0xB9,0x70,0x68,0x66,0x34};
+
 uint32_t ContainerType::read(facebook::thrift::protocol::TProtocol* iprot) {
 
   uint32_t xfer = 0;
@@ -148,6 +154,9 @@
   return xfer;
 }
 
+char* ThriftType::ascii_fingerprint = "76BC1CC759001D7D85FEE75C4F183062";
+char ThriftType::binary_fingerprint[16] = {0x76,0xBC,0x1C,0xC7,0x59,0x00,0x1D,0x7D,0x85,0xFE,0xE7,0x5C,0x4F,0x18,0x30,0x62};
+
 uint32_t ThriftType::read(facebook::thrift::protocol::TProtocol* iprot) {
 
   uint32_t xfer = 0;
@@ -225,6 +234,9 @@
   return xfer;
 }
 
+char* Argument::ascii_fingerprint = "8C45506BE0EFBB22FB19FA40DDCECB3F";
+char Argument::binary_fingerprint[16] = {0x8C,0x45,0x50,0x6B,0xE0,0xEF,0xBB,0x22,0xFB,0x19,0xFA,0x40,0xDD,0xCE,0xCB,0x3F};
+
 uint32_t Argument::read(facebook::thrift::protocol::TProtocol* iprot) {
 
   uint32_t xfer = 0;
@@ -298,6 +310,9 @@
   return xfer;
 }
 
+char* Method::ascii_fingerprint = "E6573428C492D24C84A19432D39A17B0";
+char Method::binary_fingerprint[16] = {0xE6,0x57,0x34,0x28,0xC4,0x92,0xD2,0x4C,0x84,0xA1,0x94,0x32,0xD3,0x9A,0x17,0xB0};
+
 uint32_t Method::read(facebook::thrift::protocol::TProtocol* iprot) {
 
   uint32_t xfer = 0;
@@ -392,6 +407,9 @@
   return xfer;
 }
 
+char* Service::ascii_fingerprint = "4673B0777B701D9B02A7A74CEC7908A7";
+char Service::binary_fingerprint[16] = {0x46,0x73,0xB0,0x77,0x7B,0x70,0x1D,0x9B,0x02,0xA7,0xA7,0x4C,0xEC,0x79,0x08,0xA7};
+
 uint32_t Service::read(facebook::thrift::protocol::TProtocol* iprot) {
 
   uint32_t xfer = 0;
diff --git a/lib/cpp/src/reflection_limited_types.h b/lib/cpp/src/reflection_limited_types.h
index 843c691..677cb4a 100644
--- a/lib/cpp/src/reflection_limited_types.h
+++ b/lib/cpp/src/reflection_limited_types.h
@@ -7,6 +7,7 @@
 #define reflection_limited_TYPES_H
 
 #include <Thrift.h>
+#include <reflection_limited_types.h>
 #include <protocol/TProtocol.h>
 #include <transport/TTransport.h>
 
@@ -34,6 +35,9 @@
 class SimpleType {
  public:
 
+  static char* ascii_fingerprint; // = "19B5240589E680301A7E32DF3971EFBE";
+  static char binary_fingerprint[16]; // = {0x19,0xB5,0x24,0x05,0x89,0xE6,0x80,0x30,0x1A,0x7E,0x32,0xDF,0x39,0x71,0xEF,0xBE};
+
   SimpleType() : name("") {
   }
 
@@ -68,6 +72,9 @@
 class ContainerType {
  public:
 
+  static char* ascii_fingerprint; // = "654FA6EFFF8242F4C2A604B970686634";
+  static char binary_fingerprint[16]; // = {0x65,0x4F,0xA6,0xEF,0xFF,0x82,0x42,0xF4,0xC2,0xA6,0x04,0xB9,0x70,0x68,0x66,0x34};
+
   ContainerType() {
   }
 
@@ -108,6 +115,9 @@
 class ThriftType {
  public:
 
+  static char* ascii_fingerprint; // = "76BC1CC759001D7D85FEE75C4F183062";
+  static char binary_fingerprint[16]; // = {0x76,0xBC,0x1C,0xC7,0x59,0x00,0x1D,0x7D,0x85,0xFE,0xE7,0x5C,0x4F,0x18,0x30,0x62};
+
   ThriftType() : is_container(0) {
   }
 
@@ -150,6 +160,9 @@
 class Argument {
  public:
 
+  static char* ascii_fingerprint; // = "8C45506BE0EFBB22FB19FA40DDCECB3F";
+  static char binary_fingerprint[16]; // = {0x8C,0x45,0x50,0x6B,0xE0,0xEF,0xBB,0x22,0xFB,0x19,0xFA,0x40,0xDD,0xCE,0xCB,0x3F};
+
   Argument() : key(0), name("") {
   }
 
@@ -188,6 +201,9 @@
 class Method {
  public:
 
+  static char* ascii_fingerprint; // = "E6573428C492D24C84A19432D39A17B0";
+  static char binary_fingerprint[16]; // = {0xE6,0x57,0x34,0x28,0xC4,0x92,0xD2,0x4C,0x84,0xA1,0x94,0x32,0xD3,0x9A,0x17,0xB0};
+
   Method() : name("") {
   }
 
@@ -226,6 +242,9 @@
 class Service {
  public:
 
+  static char* ascii_fingerprint; // = "4673B0777B701D9B02A7A74CEC7908A7";
+  static char binary_fingerprint[16]; // = {0x46,0x73,0xB0,0x77,0x7B,0x70,0x1D,0x9B,0x02,0xA7,0xA7,0x4C,0xEC,0x79,0x08,0xA7};
+
   Service() : name(""), fully_reflected(0) {
   }
 
diff --git a/lib/py/cleanup.sh b/lib/py/cleanup.sh
index bbbcef5..fd52c28 100755
--- a/lib/py/cleanup.sh
+++ b/lib/py/cleanup.sh
@@ -11,6 +11,7 @@
 aclocal.m4 \
 autom4te.cache \
 autoscan.log \
+build \
 config.guess \
 config.h \
 config.hin \
diff --git a/lib/py/setup.py b/lib/py/setup.py
index 582a985..c727db4 100644
--- a/lib/py/setup.py
+++ b/lib/py/setup.py
@@ -18,7 +18,14 @@
       author = ['Mark Slee'],
       author_email = ['mcslee@facebook.com'],
       url = 'http://code.facebook.com/thrift',
-      packages = ['thrift', 'thrift.protocol', 'thrift.transport', 'thrift.server'],
+      packages = [
+        'thrift',
+        'thrift.protocol',
+        'thrift.transport',
+        'thrift.server',
+        'thrift.reflection',
+        'thrift.reflection.limited',
+      ],
       package_dir = {'thrift' : 'src'},
       ext_modules = [fastbinarymod],
       )
diff --git a/lib/py/src/reflection/__init__.py b/lib/py/src/reflection/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/lib/py/src/reflection/__init__.py
diff --git a/lib/py/src/reflection/limited/__init__.py b/lib/py/src/reflection/limited/__init__.py
new file mode 100644
index 0000000..adefd8e
--- /dev/null
+++ b/lib/py/src/reflection/limited/__init__.py
@@ -0,0 +1 @@
+__all__ = ['ttypes', 'constants']
diff --git a/lib/py/src/reflection/limited/constants.py b/lib/py/src/reflection/limited/constants.py
new file mode 100644
index 0000000..2f17ec3
--- /dev/null
+++ b/lib/py/src/reflection/limited/constants.py
@@ -0,0 +1,9 @@
+#
+# Autogenerated by Thrift
+#
+# DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
+#
+
+from thrift.Thrift import *
+from ttypes import *
+
diff --git a/lib/py/src/reflection/limited/ttypes.py b/lib/py/src/reflection/limited/ttypes.py
new file mode 100644
index 0000000..9ea8a9f
--- /dev/null
+++ b/lib/py/src/reflection/limited/ttypes.py
@@ -0,0 +1,532 @@
+#
+# Autogenerated by Thrift
+#
+# DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
+#
+
+from thrift.Thrift import *
+
+from thrift.transport import TTransport
+from thrift.protocol import fastbinary
+from thrift.protocol import TBinaryProtocol
+
+
+class TTypeTag:
+  T_VOID = 1
+  T_BOOL = 2
+  T_BYTE = 3
+  T_I16 = 6
+  T_I32 = 8
+  T_I64 = 10
+  T_DOUBLE = 4
+  T_STRING = 11
+  T_STRUCT = 12
+  T_MAP = 13
+  T_SET = 14
+  T_LIST = 15
+  T_ENUM = 101
+  T_NOT_REFLECTED = 102
+
+class SimpleType:
+
+  thrift_spec = (
+    None, # 0
+    (1, TType.I32, 'ttype', None, None, ), # 1
+    (2, TType.STRING, 'name', None, None, ), # 2
+  )
+
+  def __init__(self, d=None):
+    self.ttype = None
+    self.name = None
+    if isinstance(d, dict):
+      if 'ttype' in d:
+        self.ttype = d['ttype']
+      if 'name' in d:
+        self.name = d['name']
+
+  def read(self, iprot):
+    if iprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and isinstance(iprot.trans, TTransport.CReadableTransport):
+      fastbinary.decode_binary(self, iprot.trans, (self.__class__, self.thrift_spec))
+      return
+    iprot.readStructBegin()
+    while True:
+      (fname, ftype, fid) = iprot.readFieldBegin()
+      if ftype == TType.STOP:
+        break
+      if fid == 1:
+        if ftype == TType.I32:
+          self.ttype = iprot.readI32();
+        else:
+          iprot.skip(ftype)
+      elif fid == 2:
+        if ftype == TType.STRING:
+          self.name = iprot.readString();
+        else:
+          iprot.skip(ftype)
+      else:
+        iprot.skip(ftype)
+      iprot.readFieldEnd()
+    iprot.readStructEnd()
+
+  def write(self, oprot):
+    if oprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated:
+      oprot.trans.write(fastbinary.encode_binary(self, (self.__class__, self.thrift_spec)))
+      return
+    oprot.writeStructBegin('SimpleType')
+    if self.ttype != None:
+      oprot.writeFieldBegin('ttype', TType.I32, 1)
+      oprot.writeI32(self.ttype)
+      oprot.writeFieldEnd()
+    if self.name != None:
+      oprot.writeFieldBegin('name', TType.STRING, 2)
+      oprot.writeString(self.name)
+      oprot.writeFieldEnd()
+    oprot.writeFieldStop()
+    oprot.writeStructEnd()
+
+  def __str__(self): 
+    return str(self.__dict__)
+
+  def __repr__(self): 
+    return repr(self.__dict__)
+
+  def __eq__(self, other):
+    return isinstance(other, self.__class__) and self.__dict__ == other.__dict__
+
+  def __ne__(self, other):
+    return not (self == other)
+
+class ContainerType:
+
+  thrift_spec = (
+    None, # 0
+    (1, TType.I32, 'ttype', None, None, ), # 1
+    (2, TType.STRUCT, 'subtype1', (SimpleType, SimpleType.thrift_spec), None, ), # 2
+    (3, TType.STRUCT, 'subtype2', (SimpleType, SimpleType.thrift_spec), None, ), # 3
+  )
+
+  def __init__(self, d=None):
+    self.ttype = None
+    self.subtype1 = None
+    self.subtype2 = None
+    if isinstance(d, dict):
+      if 'ttype' in d:
+        self.ttype = d['ttype']
+      if 'subtype1' in d:
+        self.subtype1 = d['subtype1']
+      if 'subtype2' in d:
+        self.subtype2 = d['subtype2']
+
+  def read(self, iprot):
+    if iprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and isinstance(iprot.trans, TTransport.CReadableTransport):
+      fastbinary.decode_binary(self, iprot.trans, (self.__class__, self.thrift_spec))
+      return
+    iprot.readStructBegin()
+    while True:
+      (fname, ftype, fid) = iprot.readFieldBegin()
+      if ftype == TType.STOP:
+        break
+      if fid == 1:
+        if ftype == TType.I32:
+          self.ttype = iprot.readI32();
+        else:
+          iprot.skip(ftype)
+      elif fid == 2:
+        if ftype == TType.STRUCT:
+          self.subtype1 = SimpleType()
+          self.subtype1.read(iprot)
+        else:
+          iprot.skip(ftype)
+      elif fid == 3:
+        if ftype == TType.STRUCT:
+          self.subtype2 = SimpleType()
+          self.subtype2.read(iprot)
+        else:
+          iprot.skip(ftype)
+      else:
+        iprot.skip(ftype)
+      iprot.readFieldEnd()
+    iprot.readStructEnd()
+
+  def write(self, oprot):
+    if oprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated:
+      oprot.trans.write(fastbinary.encode_binary(self, (self.__class__, self.thrift_spec)))
+      return
+    oprot.writeStructBegin('ContainerType')
+    if self.ttype != None:
+      oprot.writeFieldBegin('ttype', TType.I32, 1)
+      oprot.writeI32(self.ttype)
+      oprot.writeFieldEnd()
+    if self.subtype1 != None:
+      oprot.writeFieldBegin('subtype1', TType.STRUCT, 2)
+      self.subtype1.write(oprot)
+      oprot.writeFieldEnd()
+    if self.subtype2 != None:
+      oprot.writeFieldBegin('subtype2', TType.STRUCT, 3)
+      self.subtype2.write(oprot)
+      oprot.writeFieldEnd()
+    oprot.writeFieldStop()
+    oprot.writeStructEnd()
+
+  def __str__(self): 
+    return str(self.__dict__)
+
+  def __repr__(self): 
+    return repr(self.__dict__)
+
+  def __eq__(self, other):
+    return isinstance(other, self.__class__) and self.__dict__ == other.__dict__
+
+  def __ne__(self, other):
+    return not (self == other)
+
+class ThriftType:
+
+  thrift_spec = (
+    None, # 0
+    (1, TType.BOOL, 'is_container', None, None, ), # 1
+    (2, TType.STRUCT, 'simple_type', (SimpleType, SimpleType.thrift_spec), None, ), # 2
+    (3, TType.STRUCT, 'container_type', (ContainerType, ContainerType.thrift_spec), None, ), # 3
+  )
+
+  def __init__(self, d=None):
+    self.is_container = None
+    self.simple_type = None
+    self.container_type = None
+    if isinstance(d, dict):
+      if 'is_container' in d:
+        self.is_container = d['is_container']
+      if 'simple_type' in d:
+        self.simple_type = d['simple_type']
+      if 'container_type' in d:
+        self.container_type = d['container_type']
+
+  def read(self, iprot):
+    if iprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and isinstance(iprot.trans, TTransport.CReadableTransport):
+      fastbinary.decode_binary(self, iprot.trans, (self.__class__, self.thrift_spec))
+      return
+    iprot.readStructBegin()
+    while True:
+      (fname, ftype, fid) = iprot.readFieldBegin()
+      if ftype == TType.STOP:
+        break
+      if fid == 1:
+        if ftype == TType.BOOL:
+          self.is_container = iprot.readBool();
+        else:
+          iprot.skip(ftype)
+      elif fid == 2:
+        if ftype == TType.STRUCT:
+          self.simple_type = SimpleType()
+          self.simple_type.read(iprot)
+        else:
+          iprot.skip(ftype)
+      elif fid == 3:
+        if ftype == TType.STRUCT:
+          self.container_type = ContainerType()
+          self.container_type.read(iprot)
+        else:
+          iprot.skip(ftype)
+      else:
+        iprot.skip(ftype)
+      iprot.readFieldEnd()
+    iprot.readStructEnd()
+
+  def write(self, oprot):
+    if oprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated:
+      oprot.trans.write(fastbinary.encode_binary(self, (self.__class__, self.thrift_spec)))
+      return
+    oprot.writeStructBegin('ThriftType')
+    if self.is_container != None:
+      oprot.writeFieldBegin('is_container', TType.BOOL, 1)
+      oprot.writeBool(self.is_container)
+      oprot.writeFieldEnd()
+    if self.simple_type != None:
+      oprot.writeFieldBegin('simple_type', TType.STRUCT, 2)
+      self.simple_type.write(oprot)
+      oprot.writeFieldEnd()
+    if self.container_type != None:
+      oprot.writeFieldBegin('container_type', TType.STRUCT, 3)
+      self.container_type.write(oprot)
+      oprot.writeFieldEnd()
+    oprot.writeFieldStop()
+    oprot.writeStructEnd()
+
+  def __str__(self): 
+    return str(self.__dict__)
+
+  def __repr__(self): 
+    return repr(self.__dict__)
+
+  def __eq__(self, other):
+    return isinstance(other, self.__class__) and self.__dict__ == other.__dict__
+
+  def __ne__(self, other):
+    return not (self == other)
+
+class Argument:
+
+  thrift_spec = (
+    None, # 0
+    (1, TType.I16, 'key', None, None, ), # 1
+    (2, TType.STRING, 'name', None, None, ), # 2
+    (3, TType.STRUCT, 'type', (ThriftType, ThriftType.thrift_spec), None, ), # 3
+  )
+
+  def __init__(self, d=None):
+    self.key = None
+    self.name = None
+    self.type = None
+    if isinstance(d, dict):
+      if 'key' in d:
+        self.key = d['key']
+      if 'name' in d:
+        self.name = d['name']
+      if 'type' in d:
+        self.type = d['type']
+
+  def read(self, iprot):
+    if iprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and isinstance(iprot.trans, TTransport.CReadableTransport):
+      fastbinary.decode_binary(self, iprot.trans, (self.__class__, self.thrift_spec))
+      return
+    iprot.readStructBegin()
+    while True:
+      (fname, ftype, fid) = iprot.readFieldBegin()
+      if ftype == TType.STOP:
+        break
+      if fid == 1:
+        if ftype == TType.I16:
+          self.key = iprot.readI16();
+        else:
+          iprot.skip(ftype)
+      elif fid == 2:
+        if ftype == TType.STRING:
+          self.name = iprot.readString();
+        else:
+          iprot.skip(ftype)
+      elif fid == 3:
+        if ftype == TType.STRUCT:
+          self.type = ThriftType()
+          self.type.read(iprot)
+        else:
+          iprot.skip(ftype)
+      else:
+        iprot.skip(ftype)
+      iprot.readFieldEnd()
+    iprot.readStructEnd()
+
+  def write(self, oprot):
+    if oprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated:
+      oprot.trans.write(fastbinary.encode_binary(self, (self.__class__, self.thrift_spec)))
+      return
+    oprot.writeStructBegin('Argument')
+    if self.key != None:
+      oprot.writeFieldBegin('key', TType.I16, 1)
+      oprot.writeI16(self.key)
+      oprot.writeFieldEnd()
+    if self.name != None:
+      oprot.writeFieldBegin('name', TType.STRING, 2)
+      oprot.writeString(self.name)
+      oprot.writeFieldEnd()
+    if self.type != None:
+      oprot.writeFieldBegin('type', TType.STRUCT, 3)
+      self.type.write(oprot)
+      oprot.writeFieldEnd()
+    oprot.writeFieldStop()
+    oprot.writeStructEnd()
+
+  def __str__(self): 
+    return str(self.__dict__)
+
+  def __repr__(self): 
+    return repr(self.__dict__)
+
+  def __eq__(self, other):
+    return isinstance(other, self.__class__) and self.__dict__ == other.__dict__
+
+  def __ne__(self, other):
+    return not (self == other)
+
+class Method:
+
+  thrift_spec = (
+    None, # 0
+    (1, TType.STRING, 'name', None, None, ), # 1
+    (2, TType.STRUCT, 'return_type', (ThriftType, ThriftType.thrift_spec), None, ), # 2
+    (3, TType.LIST, 'arguments', (TType.STRUCT,(Argument, Argument.thrift_spec)), None, ), # 3
+  )
+
+  def __init__(self, d=None):
+    self.name = None
+    self.return_type = None
+    self.arguments = None
+    if isinstance(d, dict):
+      if 'name' in d:
+        self.name = d['name']
+      if 'return_type' in d:
+        self.return_type = d['return_type']
+      if 'arguments' in d:
+        self.arguments = d['arguments']
+
+  def read(self, iprot):
+    if iprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and isinstance(iprot.trans, TTransport.CReadableTransport):
+      fastbinary.decode_binary(self, iprot.trans, (self.__class__, self.thrift_spec))
+      return
+    iprot.readStructBegin()
+    while True:
+      (fname, ftype, fid) = iprot.readFieldBegin()
+      if ftype == TType.STOP:
+        break
+      if fid == 1:
+        if ftype == TType.STRING:
+          self.name = iprot.readString();
+        else:
+          iprot.skip(ftype)
+      elif fid == 2:
+        if ftype == TType.STRUCT:
+          self.return_type = ThriftType()
+          self.return_type.read(iprot)
+        else:
+          iprot.skip(ftype)
+      elif fid == 3:
+        if ftype == TType.LIST:
+          self.arguments = []
+          (_etype3, _size0) = iprot.readListBegin()
+          for _i4 in xrange(_size0):
+            _elem5 = Argument()
+            _elem5.read(iprot)
+            self.arguments.append(_elem5)
+          iprot.readListEnd()
+        else:
+          iprot.skip(ftype)
+      else:
+        iprot.skip(ftype)
+      iprot.readFieldEnd()
+    iprot.readStructEnd()
+
+  def write(self, oprot):
+    if oprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated:
+      oprot.trans.write(fastbinary.encode_binary(self, (self.__class__, self.thrift_spec)))
+      return
+    oprot.writeStructBegin('Method')
+    if self.name != None:
+      oprot.writeFieldBegin('name', TType.STRING, 1)
+      oprot.writeString(self.name)
+      oprot.writeFieldEnd()
+    if self.return_type != None:
+      oprot.writeFieldBegin('return_type', TType.STRUCT, 2)
+      self.return_type.write(oprot)
+      oprot.writeFieldEnd()
+    if self.arguments != None:
+      oprot.writeFieldBegin('arguments', TType.LIST, 3)
+      oprot.writeListBegin(TType.STRUCT, len(self.arguments))
+      for iter6 in self.arguments:
+        iter6.write(oprot)
+      oprot.writeListEnd()
+      oprot.writeFieldEnd()
+    oprot.writeFieldStop()
+    oprot.writeStructEnd()
+
+  def __str__(self): 
+    return str(self.__dict__)
+
+  def __repr__(self): 
+    return repr(self.__dict__)
+
+  def __eq__(self, other):
+    return isinstance(other, self.__class__) and self.__dict__ == other.__dict__
+
+  def __ne__(self, other):
+    return not (self == other)
+
+class Service:
+
+  thrift_spec = (
+    None, # 0
+    (1, TType.STRING, 'name', None, None, ), # 1
+    (2, TType.LIST, 'methods', (TType.STRUCT,(Method, Method.thrift_spec)), None, ), # 2
+    (3, TType.BOOL, 'fully_reflected', None, None, ), # 3
+  )
+
+  def __init__(self, d=None):
+    self.name = None
+    self.methods = None
+    self.fully_reflected = None
+    if isinstance(d, dict):
+      if 'name' in d:
+        self.name = d['name']
+      if 'methods' in d:
+        self.methods = d['methods']
+      if 'fully_reflected' in d:
+        self.fully_reflected = d['fully_reflected']
+
+  def read(self, iprot):
+    if iprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and isinstance(iprot.trans, TTransport.CReadableTransport):
+      fastbinary.decode_binary(self, iprot.trans, (self.__class__, self.thrift_spec))
+      return
+    iprot.readStructBegin()
+    while True:
+      (fname, ftype, fid) = iprot.readFieldBegin()
+      if ftype == TType.STOP:
+        break
+      if fid == 1:
+        if ftype == TType.STRING:
+          self.name = iprot.readString();
+        else:
+          iprot.skip(ftype)
+      elif fid == 2:
+        if ftype == TType.LIST:
+          self.methods = []
+          (_etype10, _size7) = iprot.readListBegin()
+          for _i11 in xrange(_size7):
+            _elem12 = Method()
+            _elem12.read(iprot)
+            self.methods.append(_elem12)
+          iprot.readListEnd()
+        else:
+          iprot.skip(ftype)
+      elif fid == 3:
+        if ftype == TType.BOOL:
+          self.fully_reflected = iprot.readBool();
+        else:
+          iprot.skip(ftype)
+      else:
+        iprot.skip(ftype)
+      iprot.readFieldEnd()
+    iprot.readStructEnd()
+
+  def write(self, oprot):
+    if oprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated:
+      oprot.trans.write(fastbinary.encode_binary(self, (self.__class__, self.thrift_spec)))
+      return
+    oprot.writeStructBegin('Service')
+    if self.name != None:
+      oprot.writeFieldBegin('name', TType.STRING, 1)
+      oprot.writeString(self.name)
+      oprot.writeFieldEnd()
+    if self.methods != None:
+      oprot.writeFieldBegin('methods', TType.LIST, 2)
+      oprot.writeListBegin(TType.STRUCT, len(self.methods))
+      for iter13 in self.methods:
+        iter13.write(oprot)
+      oprot.writeListEnd()
+      oprot.writeFieldEnd()
+    if self.fully_reflected != None:
+      oprot.writeFieldBegin('fully_reflected', TType.BOOL, 3)
+      oprot.writeBool(self.fully_reflected)
+      oprot.writeFieldEnd()
+    oprot.writeFieldStop()
+    oprot.writeStructEnd()
+
+  def __str__(self): 
+    return str(self.__dict__)
+
+  def __repr__(self): 
+    return repr(self.__dict__)
+
+  def __eq__(self, other):
+    return isinstance(other, self.__class__) and self.__dict__ == other.__dict__
+
+  def __ne__(self, other):
+    return not (self == other)
+
