eberle1080/dulwich-py3k — Issue #3: Remove (or minimize) the conversion decorators
Author: eberle1080
Created: 2011-11-07 14:32:38+00:00
State: open

The port is finished, but it relies very heavily on decorators to do a lot of the heavy lifting. In particular, `wrap3kstr` and `convert3kstr`. These are simple wrapper methods I wrote (the first is a decorator) that transparently converts between `String` and `Bytes` objects.

They're very nice, and very necessary, but they slow things down considerably and make the code behave in a mysterious fashion (passing in a string may result in a bytes object being returned, hardly intuitive). I believe strongly in the principle of least astonishment, so I'd like to remove these things slowly, instead preferring explicit conversions and type checking (assertions?).

To support this, I've added a flag to the `wrap3kstr` decorator: `enforcing=True`. This does an assert on the type, rather than a conversion. This should allow me to slowly convert the calling code into something explicit, and eventually get rid of the decorators completely.