You need to clearly indicate whether you are using MQ (WebSphere MQ aka MQSeries) or MQTT aka WebSphere MQ Telemetry.
If you're using MQ, then definitely check out PyMQI, which looks pretty good at this point - here is a recent example on how to use this.
For MQTT, which is a lightweight messaging protocol that can interact with WebSphere MQ with the right components, then the mosquitto project provides the Python API and some examples that use it.
I'm afraid I'm not a Python expert, so I'm not quite sure how you would optimize everything around.
source share