set_operations.rst 672 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. .. _set-ops:
  2. Native set operations
  3. ======================
  4. These ``set`` operations have fast, optimized implementations. Other
  5. set operations use generic implementations that are often slower.
  6. Construction
  7. ------------
  8. Construct set with specific items:
  9. * ``{item0, ..., itemN}``
  10. Construct empty set:
  11. * ``set()``
  12. Construct set from iterable:
  13. * ``set(x: Iterable)``
  14. Set comprehensions:
  15. * ``{... for ... in ...}``
  16. * ``{... for ... in ... if ...}``
  17. Operators
  18. ---------
  19. * ``item in s``
  20. Methods
  21. -------
  22. * ``s.add(item)``
  23. * ``s.remove(item)``
  24. * ``s.discard(item)``
  25. * ``s.update(x: Iterable)``
  26. * ``s.clear()``
  27. * ``s.pop()``
  28. Functions
  29. ---------
  30. * ``len(s: set)``