Skip to content
Preptima
hardConceptMidSeniorStaff

When would you reach for an abstract base class rather than a Protocol, and what does isinstance check in each case?

Use a Python ABC when you need nominal inheritance and runtime instantiation checks; use a Protocol when a type checker should accept any object with the required methods, even without inheritance. Use this abstract base classes answer to show the decision, trade-off, and evidence rather than a memorised definition. It also connects protocols to the point an interviewer is testing.

5 min readUpdated 2026-08-15Target archetype: Big Tech, Enterprise Captive, Product Startup

Answer

Short answer

Reach for an ABC when implementers should explicitly inherit a shared contract or mixin behavior. Reach for a Protocol when the consumer only needs a structural shape, because static type checkers can accept third-party or test objects that already match it.

Was this answer helpful?

Likely follow-ups

  • Why does an abstract method raise at instantiation rather than when the subclass is defined?
  • What does ABCMeta.register buy you, and what does it deliberately not check?
  • Why is issubclass rejected for a protocol that declares data attributes?
  • How do the mixin methods in collections.abc change the argument for inheriting from one?

Related questions

Further reading

Related Topics