10
Developers’ Day 2002 Making classes look like types (and vice versa) Or…

Developers Day 2002 Making classes look like types (and vice versa) Or…

Embed Size (px)

Citation preview

Page 1: Developers Day 2002 Making classes look like types (and vice versa) Or…

Developers’ Day 2002

Making classes look like types (and vice versa)

Or…

Page 2: Developers Day 2002 Making classes look like types (and vice versa) Or…

Developers’ Day 2002

Compound W for Python’s object model

Or…

Page 3: Developers Day 2002 Making classes look like types (and vice versa) Or…

Developers’ Day 2002

Goading Guido into describing something only he (fully)

understands

Page 4: Developers Day 2002 Making classes look like types (and vice versa) Or…

4

(C) 2002 Zope Corp.

New stuff…New stuff…

• properties

• descriptors (?)

• old-style classes (ok, old stuff)

• new builtins– object, super, property, staticmethod,

classmethod, dict, …

• new-style classes

• method resolution order

Page 5: Developers Day 2002 Making classes look like types (and vice versa) Or…

5

(C) 2002 Zope Corp.

What about metaclasses…?What about metaclasses…?

Page 6: Developers Day 2002 Making classes look like types (and vice versa) Or…

6

(C) 2002 Zope Corp.

What about metaclasses…?What about metaclasses…?

>>> brain.kaboom()

Page 7: Developers Day 2002 Making classes look like types (and vice versa) Or…

7

(C) 2002 Zope Corp.

More new stuff…More new stuff…

• __getattribute__()

• property interface– __get__()

– __set__()

– __delete__()

• __slots__

• __mro__

• __new__()

Page 8: Developers Day 2002 Making classes look like types (and vice versa) Or…

8

(C) 2002 Zope Corp.

Issues…Issues…

• Status of PEPs 252, 253, 254

• More syntactic support– staticmethod

– classmethod, etc…

• Limitations in extending C types– Adding C slots

• Documenting everything

Page 9: Developers Day 2002 Making classes look like types (and vice versa) Or…

9

(C) 2002 Zope Corp.

Questions…Questions…

• Has anybody used it for real?

• Usability?

• Functionality?

• Promoting this stuff from experimental status

• Getting rid of classic classes?

• Performance?

Page 10: Developers Day 2002 Making classes look like types (and vice versa) Or…

10

(C) 2002 Zope Corp.

References…References…

http://www.python.org/2.2/descrintro.html

http://python.sf.net/peps/pep-0252.html

http://python.sf.net/peps/pep-0253.html

http://python.sf.net/peps/pep-0254.html

Putting Metaclasses to Work: A New Dimension in Object-Oriented Programming, by Ira R. Forman and Scott H. Danforth. Addison-Wesley, 1999, ISBN 0-201-43305-2.