If request_type can be present in more than one category, you can use the tuple to scroll them in order of priority:
categories = ( (category1, dispatch1method), (category2, dispatch2method), (category3, dispatch3method), (category4, dispatch4method), (category5, dispatch5method), ) next(method for cat, method in categories if request_type in cat)(arguments)
Otherwise, use dict() to map category types to submit methods; reuse of the same tuple-tuple to create a dispatch:
category_dispatch = {} for cat, dispatch in categories: category_dispatch.update(dict.fromkeys(cat.keys(), dispatch))
Then just find the type of request:
category_dispatch[request_type](arguments)
Such a matching search will be faster than scanning through a tuple, where we must test each category in turn until we find a match.
In fact, the order of priorities can be maintained by changing the same tuple structure as follows:
category_dispatch = {} for cat, dispatch in reversed(categories): category_dispatch.update(dict.fromkeys(cat.keys(), dispatch))
since now the highest priority mapping for this key request_type will be introduced into the category_dispatch last structure. This will give you the fastest sending, even if request types were present in several categories.
The disadvantage is that if your category* mappings are dynamic (query types are added and removed from different categories over time), you need to maintain a category_dispatch dict to reflect these changes.