MCPcopy Index your code
hub / github.com/python/cpython / getcontext

Function getcontext

Lib/_pydecimal.py:356–368  ·  view source on GitHub ↗

Returns this thread's context. If this thread does not yet have a context, returns a new context and sets this thread's context. New contexts are copies of DefaultContext.

()

Source from the content-addressed store, hash-verified

354)
355
356def getcontext():
357 """Returns this thread's context.
358
359 If this thread does not yet have a context, returns
360 a new context and sets this thread's context.
361 New contexts are copies of DefaultContext.
362 """
363 try:
364 return _current_context_var.get()
365 except LookupError:
366 context = Context()
367 _current_context_var.set(context)
368 return context
369
370def setcontext(context):
371 """Set this thread's context to context."""

Callers 15

localcontextFunction · 0.85
__new__Method · 0.85
_check_nansMethod · 0.85
_compare_check_nansMethod · 0.85
__str__Method · 0.85
__neg__Method · 0.85
__pos__Method · 0.85
__add__Method · 0.85
__mul__Method · 0.85
__truediv__Method · 0.85
__divmod__Method · 0.85
__mod__Method · 0.85

Calls 3

ContextClass · 0.70
getMethod · 0.45
setMethod · 0.45

Tested by 13

thfunc1Function · 0.68
thfunc2Function · 0.68
test_implicit_contextMethod · 0.68
test_localcontextMethod · 0.68
test_localcontextargMethod · 0.68
test_default_contextMethod · 0.68
test_canonicalMethod · 0.68
test_radixMethod · 0.68
test_c_context_errorsMethod · 0.68

Used in the wild real call sites across dependent graphs

searching dependent graphs…