title: Searching "easy" approach for `tp_repr` and `tp_str`
body: <p>I am creating an Python extension in C, for having a friendly structure and efficient usage on it. So there is a lot of source code for certain heavy operations which should be in C. And a lot of internal fields are referenced.</p>
  
  <p>Now, I was going to do some aesthetic improvements: mainly the <code>tp_repr</code> and <code>tp_str</code> slots. Must I do them in C? I am thinking that doing them in Python should be easy, but coding it in C seems to be a nightmare and useless.</p>
  
  <p>I have internal fields like encoded binary strings, a dictionary, and so on. Using Python features seems straightforward:</p>
  
  <pre><code>def repr_func(obj):
      return "MyObject(name='%s'.encode('utf-16-be'), id=%d, map=%s)"
              % (obj.name.decode("utf-16-be"), obj.id, repr(obj.map))
  </code></pre>
  
  <p>I know I could do this in C, but it seems cleaner to do it in Python. I do not need performance, those will be used for debugging and testing, so I need them to be useful and clean.</p>
  
  <p>Is there some way to do this without deep changes in the C source?</p>