Skip to content

Provide an abstract class hierarchy for the common interface #689

@ystradmann

Description

@ystradmann

Hi,

for clarification of the types and methods a backend has to implement, it would be nice if pyNN's interface would be defined by python's Abstract Base Classes. The corresponding PEP 3119 constitutes the usage of ABCs (among others) as

In addition, the ABCs define a minimal set of methods that establish the characteristic behavior of the type. Code that discriminates objects based on their ABC type can trust that those methods will always be present.

– which describes the requirement of all pyNN backends to behave similarly very well.

I see several advantages from such an architecture:

  • When implementing a new backend, it's very clear what (minimally) needs to be implemented – without the need for looking at calling code
  • If a feature is not implemented in one of the backends, a descriptive error of the instantiated class being abstract will be thrown by the interpreter
  • The official pyNN-API would be well defined in-code and not rely on conventions (functionality that every backend implements)

I am aware that implementing this concept might require refactoring of substantial parts of the codebase. This issue should therefore be understood as a suggestion for a potential enhancement of pyNN; it's in no way to be seen as a bug report.

Best,
Yannik

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions