#35984: functools.singledispatchmethod on Django models don't work
-------------------------------------+-------------------------------------
     Reporter:  Simon Gomizelj       |                    Owner:  (none)
         Type:  Bug                  |                   Status:  closed
    Component:  Database layer       |                  Version:  4.2
  (models, ORM)                      |
     Severity:  Normal               |               Resolution:  needsinfo
     Keywords:                       |             Triage Stage:
                                     |  Unreviewed
    Has patch:  0                    |      Needs documentation:  0
  Needs tests:  0                    |  Patch needs improvement:  0
Easy pickings:  0                    |                    UI/UX:  0
-------------------------------------+-------------------------------------
Comment (by Simon Gomizelj):

 I know what the issue is. There's a weak key map under the hood:

 {{{#!python
 class singledispatchmethod:
     # snip

     def __get__(self, obj, cls=None):
         if self._method_cache is not None:
             try:
                 _method = self._method_cache[obj]
             except TypeError:
                 self._method_cache = None
             except KeyError:
                 pass
             else:
                 return _method
 }}}

 Since Django models `__hash__` is driven by the pk, this is fundamentally
 incompatible with this optimization.
-- 
Ticket URL: <https://code.djangoproject.com/ticket/35984#comment:4>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion visit 
https://groups.google.com/d/msgid/django-updates/01070193a8d11e30-3d13dd9d-babf-403d-a161-d3f54c0a4b62-000000%40eu-central-1.amazonses.com.

Reply via email to