Complex voodoo magic goes on here. For this example... @jsonify.when('isinstance(obj, Binary)') def jsonify_binary(obj): return str(obj).encode('base64') Why not instead use something like: def jsonify(obj): if isinstance(obj, Binary): return str(obj).encode('base64') Instead you are adding more requirements, dependencies, and making the code harder to read. I know this was just an exercise in playing around with generic functions, but please think of simplicity. Please let me know what this method gives over simple if else? Here is a rewritten version of your jsonify.py using if else instead of . def jsonify(obj): # @@: Should this match all iterables? if isinstance(obj, (int, float, str, unicode)): return jsonify_simple(obj) else if isinstance(obj, (list, tuple)): return jsonify_list(obj) else if isinstance(obj, dict)'): return jsonify_dict(obj): else if isinstance(obj, sqlobject.SQLObject): return jsonify_sqlobject(obj): else if hasattr(obj, "__json__"): return jsonify_explicit(obj): else if isinstance(obj, sqlobject.SQLObject.SelectResultsClass): return jsonify_select_results(obj): def jsonify_simple(obj): return obj def jsonify_list(obj): return [jsonify(v) for v in obj] def jsonify_dict(obj): result = {} for name in obj: if not isinstance(name, (str, unicode)): raise ValueError( "Cannot represent dictionaries with non-string keys in JSON (found: %r)" % name) result[name] = jsonify(obj[name]) return result def jsonify_sqlobject(obj): result = {} result['id'] = obj.id for name in obj.sqlmeta.columns.keys(): result[name] = getattr(obj, name) return result def jsonify_explicit(obj): return obj.__json__() def jsonify_select_results(obj): return jsonify_list(obj) The difference is that all your rules are in the same place. Which makes the ordering of rules easier to see. Another difference is that there are a few less lines... but I could change the if/else example to use less with less readability too. The main difference is that the if else version would work in more places, and more random python programmers would understand it.