Commit 3e7259a7 authored by Jason Madden's avatar Jason Madden

Move the second class into the proof.

The reader doesn't need to see the class that doesn't define eq and hash.
parent 9ea0214a
......@@ -574,25 +574,23 @@ For example, a class that defines ``__eq__`` and ``__hash__`` like this::
is going to be much slower to use as a key in a persistent dictionary,
or in a new dictionary when the key is a ghost, than the class that
inherits identity-based ``__eq__`` and ``__hash__``::
inherits identity-based ``__eq__`` and ``__hash__``.
class Book(persistent.Persistent):
def __init__(self, title):
self.title = title
self.authors = ()
.. Example of the above.
def add_author(self, author):
self.authors += (author, )
Here's what that class would look like::
.. -> src
>>> exec(src)
>>> class Book(persistent.Persistent):
... def __init__(self, title):
... self.title = title
... self.authors = ()
...
... def add_author(self, author):
... self.authors += (author, )
Lets see an example of how these classes behave when stored in a
dictionary. First, lets store some dictionaries::
>>> import ZODB
>>> db = ZODB.DB(None)
>>> conn1 = db.open()
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment