9

I noticed that the sqlite3-library still uses the __conform__-method to adapt objects for storage in a database.

Then you need to give your class a method __conform__(self, protocol) which must return the converted value.

^ Python docs 12.6.6.2.1 ^

This seems to follow PEP 246, which specifies the __conform__-method, but it has been rejected;

I'm rejecting this PEP. Something much better is about to happen; it's too early to say exactly what, but it's not going to resemble the proposal in this PEP too closely so it's better to start a new PEP. GvR.

^ Rejection notice of PEP 246 ^

Now, how can it be that an official Python library implements a standard that has been defined in a suggestion that has explicitly been rejected?

Tess E. Duursma
  • 186
  • 1
  • 8

1 Answers1

5

PEP 246 was a suggestion to implement a particular design pattern (testing if an incoming object adhered to a given protocol) using a particular name. The proposal, if accepted, would have added a new special method to the Python language (__conform__), as well as a new built-in function (adapt).

The PEP decision simply rejected standardization. It does not prohibit any Python package designers from creating and using such a pattern/naming convention internally in their code. This is analogous to the freedom the sqlite3 developers have in naming the Cursor method fetchone() rather than fetchnext(). They can name/design their package components however they like, within reason and utility.

Update - according to Eric Snow, regarding the 'something much better' that was promised to be coming:

At the time it referred to generic functions (a la PEP 3124: Overloading, Generic Functions, Interfaces, and Adaptation). However, ultimately it was Abstract Base Classes (PEP 3119) that slid into this space.

HFBrowning
  • 2,196
  • 3
  • 23
  • 42
  • 3
    I'm accepting this answer, but I'd still like to know what "Something much better" in "Something much better is about to happen" was meant to mean, as I genuinely could not find it. (If you don't know it, please do say so.) – Tess E. Duursma May 18 '19 at 17:29
  • 2
    @ThomasE.Duursma I don't know either - and I agree, that comment by Guido is rather enigmatic :) I'll keep searching and update my answer if ever I find it. – HFBrowning May 20 '19 at 17:10
  • 2
    @ThomasE.Duursma I told you I'd update the answer if I **ever** found the answer to your question. Two years later here we are :) – HFBrowning Jun 28 '21 at 15:15
  • 1
    WOW! I just saw the little badge on my inbox. Thank you for the update! This is awesome. – Tess E. Duursma Sep 12 '21 at 12:48