Sivan Greenberg schrieb am 30.07.2016 um 23:15: > I'm wondering about the use of partial in writing parallel code. Is is it > quicker than re-evaluating arguments for a multiple session.get()'s method > with different , for example (of requests) ? > > Or maybe it is used to make sure the arguments differ per each invocation > ? (the parallel invocation is supposedly using tasks / co-routine support > in Python 3. > > I can't publish the code I spotted that in. > > What are ups and downs of using them when are they in context?
I'm having difficulties in understanding what exactly you are asking here and what you are comparing it with, but partial() is just a way of saying "I want a single thing that calls *this* function with at least (or exactly) *these* arguments whenever I call it". It's basically binding a function and some arguments together into a nice package that the eventual caller doesn't have to know any special details about. There is more than one way to do that, but partial is a quick and straight forward one that is commonly and widely used. Also for entry points when running code in parallel or concurrently, but there's really nothing special about that use case. Does that answer your question? Stefan -- https://mail.python.org/mailman/listinfo/python-list