parameters: (class_name, ns='::', is_prefix=False)
return_statement: return pythonization_impl
docstring: Decorator that allows to pythonize C++ classes. To pythonize means to add
      some extra behaviour to a C++ class that is used from Python via PyROOT,
      so that such a class can be used in an easier / more "pythonic" way.
      When a pythonization is registered with this decorator, the injection of
      the new behaviour in the C++ class is done immediately, if the class has
      already been used from the application, or lazily, i.e. only when the class
      is first accessed from the application.
  
      Args:
          class_name (string/iterable[string]): specifies either a single string or
              multiple strings, where each string can be either (i) the name of a
              C++ class to be pythonized, or (ii) a prefix to match all classes
              whose name starts with that prefix.
          ns (string): namespace of the classes to be pythonized. Default is the
              global namespace (`::`).
          is_prefix (boolean): if True, `class_name` contains one or multiple
              prefixes, each prefix potentially matching multiple classes.
              Default is False.
              These are examples of prefixes and namespace and what they match:
              - class_name="", ns="::" : all classes in the global namespace.
              - class_name="C", ns="::" : all classes in the global namespace
                whose name starts with "C"
              - class_name="", ns="NS1::NS2" : all classes in namespace "NS1::NS2"
              - class_name="C", ns="NS1::NS2" : all classes in namespace
                "NS1::NS2" whose name starts with "C"
  
      Returns:
          function: function that receives the user-defined function and
              decorates it.
docstring_summary: Decorator that allows to pythonize C++ classes. To pythonize means to add
      some extra behaviour to a C++ class that is used from Python via PyROOT,
      so that such a class can be used in an easier / more "pythonic" way.
      When a pythonization is registered with this decorator, the injection of
      the new behaviour in the C++ class is done immediately, if the class has
      already been used from the application, or lazily, i.e. only when the class
      is first accessed from the application.
docstring_tokens: Decorator that allows to pythonize C ++ classes . To pythonize means to add some extra behaviour to a C ++ class that is used from Python via PyROOT so that such a class can be used in an easier / more pythonic way . When a pythonization is registered with this decorator the injection of the new behaviour in the C ++ class is done immediately if the class has already been used from the application or lazily i . e . only when the class is first accessed from the application .
function: def pythonization(class_name, ns='::', is_prefix=False):
      '''
      Decorator that allows to pythonize C++ classes. To pythonize means to add
      some extra behaviour to a C++ class that is used from Python via PyROOT,
      so that such a class can be used in an easier / more "pythonic" way.
      When a pythonization is registered with this decorator, the injection of
      the new behaviour in the C++ class is done immediately, if the class has
      already been used from the application, or lazily, i.e. only when the class
      is first accessed from the application.
  
      Args:
          class_name (string/iterable[string]): specifies either a single string or
              multiple strings, where each string can be either (i) the name of a
              C++ class to be pythonized, or (ii) a prefix to match all classes
              whose name starts with that prefix.
          ns (string): namespace of the classes to be pythonized. Default is the
              global namespace (`::`).
          is_prefix (boolean): if True, `class_name` contains one or multiple
              prefixes, each prefix potentially matching multiple classes.
              Default is False.
              These are examples of prefixes and namespace and what they match:
              - class_name="", ns="::" : all classes in the global namespace.
              - class_name="C", ns="::" : all classes in the global namespace
                whose name starts with "C"
              - class_name="", ns="NS1::NS2" : all classes in namespace "NS1::NS2"
              - class_name="C", ns="NS1::NS2" : all classes in namespace
                "NS1::NS2" whose name starts with "C"
  
      Returns:
          function: function that receives the user-defined function and
              decorates it.
      '''
  
      # Type check and parsing of target argument.
      # Retrieve the scope(s) of the class(es)/prefix(es) to register the
      # pythonizor in the right scope(s)
      target = _check_target(class_name)
  
      # Remove trailing '::' from namespace
      if ns.endswith('::'):
          ns = ns[:-2]
  
      # Create a filter lambda for the target class(es)/prefix(es)
      if is_prefix:
          def passes_filter(class_name):
              return any(class_name.startswith(prefix)
                         for prefix in target)
      else:
          def passes_filter(class_name):
              return class_name in target
  
      def pythonization_impl(user_pythonizor):
          '''
          The real decorator. Accepts a user-provided function and decorates it.
          An inner function - a wrapper of the user function - is registered in
          cppyy as a pythonizor.
  
          Args:
              user_pythonizor (function): user-provided function to be decorated.
                  It implements some pythonization. It can accept two parameters:
                  the class to be pythonized, i.e. the Python proxy of the class
                  in which new behaviour can be injected, and optionally the name
                  of that class (can be used e.g. to do some more complex
                  filtering).
  
          Returns:
              function: the user function, after being registered as a
                  pythonizor.
          '''
  
          npars = _check_num_pars(user_pythonizor)
  
          # Check whether any of the target classes has already been used.
          # If so, the class proxy has to be immediately pythonized - even if we
          # registered a pythonizor for it, the pythonizor would never be executed
          _find_used_classes(ns, passes_filter, user_pythonizor, npars)
  
          def cppyy_pythonizor(klass, name):
              '''
              Wrapper function with the parameters that cppyy requires for a
              pythonizor function (class proxy and class name). It invokes the
              user function only if the current class - a candidate for being
              pythonized - matches the `target` argument of the decorator.
  
              Args:
                  klass (class type): cppyy proxy of the class that is the
                      current candidate to be pythonized.
                  name (string): name of the class that is the current candidate
                      to be pythonized.
              '''
  
              fqn = klass.__cpp_name__
  
              # Add pretty printing (done on all classes)
              pythonize_generic(klass, fqn)
  
              if passes_filter(name):
                  _invoke(user_pythonizor, npars, klass, fqn)
  
          # Register pythonizor in its namespace
          cppyy.py.add_pythonization(cppyy_pythonizor, ns)
  
          # Return the original user function.
          # We don't want to modify the user function, we just use the decorator
          # to register the function as a pythonizor.
          # This allows for correct chaining of multiple @pythonization decorators
          # for a single function
          return user_pythonizor
  
      return pythonization_impl
function_tokens: def pythonization ( class_name , ns = '::' , is_prefix = False ) : # Type check and parsing of target argument. # Retrieve the scope(s) of the class(es)/prefix(es) to register the # pythonizor in the right scope(s) target = _check_target ( class_name ) # Remove trailing '::' from namespace if ns . endswith ( '::' ) : ns = ns [ : - 2 ] # Create a filter lambda for the target class(es)/prefix(es) if is_prefix : def passes_filter ( class_name ) : return any ( class_name . startswith ( prefix ) for prefix in target ) else : def passes_filter ( class_name ) : return class_name in target def pythonization_impl ( user_pythonizor ) : '''
          The real decorator. Accepts a user-provided function and decorates it.
          An inner function - a wrapper of the user function - is registered in
          cppyy as a pythonizor.
  
          Args:
              user_pythonizor (function): user-provided function to be decorated.
                  It implements some pythonization. It can accept two parameters:
                  the class to be pythonized, i.e. the Python proxy of the class
                  in which new behaviour can be injected, and optionally the name
                  of that class (can be used e.g. to do some more complex
                  filtering).
  
          Returns:
              function: the user function, after being registered as a
                  pythonizor.
          ''' npars = _check_num_pars ( user_pythonizor ) # Check whether any of the target classes has already been used. # If so, the class proxy has to be immediately pythonized - even if we # registered a pythonizor for it, the pythonizor would never be executed _find_used_classes ( ns , passes_filter , user_pythonizor , npars ) def cppyy_pythonizor ( klass , name ) : '''
              Wrapper function with the parameters that cppyy requires for a
              pythonizor function (class proxy and class name). It invokes the
              user function only if the current class - a candidate for being
              pythonized - matches the `target` argument of the decorator.
  
              Args:
                  klass (class type): cppyy proxy of the class that is the
                      current candidate to be pythonized.
                  name (string): name of the class that is the current candidate
                      to be pythonized.
              ''' fqn = klass . __cpp_name__ # Add pretty printing (done on all classes) pythonize_generic ( klass , fqn ) if passes_filter ( name ) : _invoke ( user_pythonizor , npars , klass , fqn ) # Register pythonizor in its namespace cppyy . py . add_pythonization ( cppyy_pythonizor , ns ) # Return the original user function. # We don't want to modify the user function, we just use the decorator # to register the function as a pythonizor. # This allows for correct chaining of multiple @pythonization decorators # for a single function return user_pythonizor return pythonization_impl