User Tools

Site Tools


python

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
python [2025/10/08 20:51] – carlpython [2026/09/09 19:44] (current) – carl
Line 36: Line 36:
  
  
 +==== Problems with Multi Interpreters ====
 +Very few Python modules support it.  It's hard to tell which ones do support it, and the support seems arbitrary.
 +
 +
 +Multiprocessing skips the ''atexit'' hooks, meaning it's not possible to do process-wide cleanup work.  They are silently skipped.
  
 ==== Problems with Descriptors ====  ==== Problems with Descriptors ==== 
Line 51: Line 56:
  
 In this, if a or b have side-effects on evaluation, like throwing an exception, the order in which a and b are invoked matters. In this, if a or b have side-effects on evaluation, like throwing an exception, the order in which a and b are invoked matters.
 +
 +
 +==== Futures ====
 +
 +  * Futures don't have a getstate() method.  This means trying to find out the running/finished/cancel/pending states of a future are racy.   The lock (condition) on the future is also private, so it's not safe to lock and query each of the state methods.
 +
 +
 +
 +==== Memory ====
 +
 +Python does not have a compacting garbage collector, so memory allocations eventually fill up RSS.   When a mixture of long lived and short lived objects are allocated around the same time, Python (pymalloc) allocates them possibly in the same arena.  When the short lived object is free, the long lived object holds the arena alive for ever.
 +
 +
 +==== Misc. APIs ====
 +List and Tuple types have an ''index'' method, but it throws if the element isn't present.   This forces you to use Exceptions as flow control.
 +
 +''set()'' objects don't support the ''del'' keyword:
 +
 +    >>> s = set()
 +    >>> s.add(99)
 +    >>> del s[99]
 +    Traceback (most recent call last):
 +      File "<stdin>", line 1, in <module>
 +    TypeError: 'set' object doesn't support item deletion
 +
 +
 +''enumerate(iterable, start=0)''
 +
 +The ''start'' parameter doesn't do what I expect.   I would have expected it to start at the element listed, but instead it just adds start to the returned tuple index:
 +
 +    >>> for i, k in  enumerate([9, 8, 7], 1): print (i, k)
 +    ... 
 +    1 9
 +    2 8
 +    3 7
 +
 +I would have expected this to return 2 total elements instead:
 +
 +    ...
 +    1 8
 +    2 7
 + 
 +
 +
python.1759956696.txt.gz · Last modified: by carl