Consider making Decimal's context use PEP 567

Decimal could just pull its Context object from a context variable rather than having to pass it in to all functions. This would be similar to how numpy works.

On Feb 7, 2018 1:54 PM, "Neil Girdhar" <mistersheik@gmail.com> wrote: Decimal could just pull its Context object from a context variable rather than having to pass it in to all functions. This would be similar to how numpy works. Decimal has always used a thread local context the same way numpy does, and in 3.7 it's switching to use a PEP 567 context: https://bugs.python.org/issue32630 -n

Wow, that's awesome! I didn't notice that when I checked. It seemed like context had to be passed in. If it were me, I would probably deprecate those context=None arguments now that we have such a clean solution. On Wed, Feb 7, 2018 at 5:32 PM Nathaniel Smith <njs@pobox.com> wrote:

On 8 February 2018 at 08:36, Neil Girdhar <mistersheik@gmail.com> wrote:
The context=None feature is there so that developers can write pure Decimal operations if they choose to do so, rather than always depending on implicit dynamic state. Cheers, Nick. -- Nick Coghlan | ncoghlan@gmail.com | Brisbane, Australia

On Feb 7, 2018 1:54 PM, "Neil Girdhar" <mistersheik@gmail.com> wrote: Decimal could just pull its Context object from a context variable rather than having to pass it in to all functions. This would be similar to how numpy works. Decimal has always used a thread local context the same way numpy does, and in 3.7 it's switching to use a PEP 567 context: https://bugs.python.org/issue32630 -n

Wow, that's awesome! I didn't notice that when I checked. It seemed like context had to be passed in. If it were me, I would probably deprecate those context=None arguments now that we have such a clean solution. On Wed, Feb 7, 2018 at 5:32 PM Nathaniel Smith <njs@pobox.com> wrote:

On 8 February 2018 at 08:36, Neil Girdhar <mistersheik@gmail.com> wrote:
The context=None feature is there so that developers can write pure Decimal operations if they choose to do so, rather than always depending on implicit dynamic state. Cheers, Nick. -- Nick Coghlan | ncoghlan@gmail.com | Brisbane, Australia
participants (3)
-
Nathaniel Smith
-
Neil Girdhar
-
Nick Coghlan