class_docstr: Context manager for enabling and disabling the global string cache.
  
  :class:`Categorical` columns created under the same global string cache have
  the same underlying physical value when string values are equal. This allows the
  columns to be concatenated or used in a join operation, for example.
  
  Notes
  -----
  Enabling the global string cache introduces some overhead.
  The amount of overhead depends on the number of categories in your data.
  It is advised to enable the global string cache only when strictly necessary.
  
  If `StringCache` calls are nested, the global string cache will only be disabled
  and cleared when the outermost context exits.
  
  Examples
  --------
  Construct two Series using the same global string cache.
  
  >>> with pl.StringCache():
  ...     s1 = pl.Series("color", ["red", "green", "red"], dtype=pl.Categorical)
  ...     s2 = pl.Series("color", ["blue", "red", "green"], dtype=pl.Categorical)
  
  As both Series are constructed under the same global string cache,
  they can be concatenated.
  
  >>> pl.concat([s1, s2])
  shape: (6,)
  Series: 'color' [cat]
  [
          "red"
          "green"
          "red"
          "blue"
          "red"
          "green"
  ]
  
  The class can also be used as a function decorator, in which case the string cache
  is enabled during function execution, and disabled afterwards.
  
  >>> @pl.StringCache()
  ... def construct_categoricals() -> pl.Series:
  ...     s1 = pl.Series("color", ["red", "green", "red"], dtype=pl.Categorical)
  ...     s2 = pl.Series("color", ["blue", "red", "green"], dtype=pl.Categorical)
  ...     return pl.concat([s1, s2])
class_docstr_tok: ["Context","manager","for","enabling","and","disabling","the","global","string","cache",".",":","class",":","`","Categorical","`","columns","created","under","the","same","global","string","cache","have","the","same","underlying","physical","value","when","string","values","are","equal",".","This","allows","the","columns","to","be","concatenated","or","used","in","a","join","operation",",","for","example",".","Notes","--","--","-","Enabling","the","global","string","cache","introduces","some","overhead",".","The","amount","of","overhead","depends","on","the","number","of","categories","in","your","data",".","It","is","advised","to","enable","the","global","string","cache","only","when","strictly","necessary",".","If","`","StringCache","`","calls","are","nested",",","the","global","string","cache","will","only","be","disabled","and","cleared","when","the","outermost","context","exits",".","Examples","--","--","--","--","Construct","two","Series","using","the","same","global","string","cache",".",">",">",">","with","pl.StringCache","(",")",":","...","s1","=","pl.Series","(","``","color","''",",","[","``","red","''",",","``","green","''",",","``","red","''","]",",","dtype=pl.Categorical",")","...","s2","=","pl.Series","(","``","color","''",",","[","``","blue","''",",","``","red","''",",","``","green","''","]",",","dtype=pl.Categorical",")","As","both","Series","are","constructed","under","the","same","global","string","cache",",","they","can","be","concatenated",".",">",">",">","pl.concat","(","[","s1",",","s2","]",")","shape",":","(","6",",",")","Series",":","'color","'","[","cat","]","[","``","red","''","``","green","''","``","red","''","``","blue","''","``","red","''","``","green","''","]","The","class","can","also","be","used","as","a","function","decorator",",","in","which","case","the","string","cache","is","enabled","during","function","execution",",","and","disabled","afterwards",".",">",">",">","@","pl.StringCache","(",")","...","def","construct_categoricals","(",")","-",">","pl.Series",":","...","s1","=","pl.Series","(","``","color","''",",","[","``","red","''",",","``","green","''",",","``","red","''","]",",","dtype=pl.Categorical",")","...","s2","=","pl.Series","(","``","color","''",",","[","``","blue","''",",","``","red","''",",","``","green","''","]",",","dtype=pl.Categorical",")","...","return","pl.concat","(","[","s1",",","s2","]",")"]
code: def __exit__(
      self,
      exc_type: type[BaseException] | None,
      exc_val: BaseException | None,
      exc_tb: TracebackType | None,
  ) -> None:
      del self._string_cache
  
file_path: polars/py-polars/polars/string_cache.py
imports: from __future__ import annotations
  import contextlib
  from typing import TYPE_CHECKING
  from polars.utils.deprecation import issue_deprecation_warning
label_desc: Use image node_id 2 for calling the StringCache obj's underlying member method code with example usage: obj.__exit__(exc_type, exc_val, exc_tb) without return types