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:: ...@@ -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, 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 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): .. Example of the above.
def __init__(self, title): Here's what that class would look like::
self.title = title
self.authors = ()
def add_author(self, author): >>> class Book(persistent.Persistent):
self.authors += (author, ) ... def __init__(self, title):
... self.title = title
.. -> src ... self.authors = ()
...
>>> exec(src) ... def add_author(self, author):
... self.authors += (author, )
Lets see an example of how these classes behave when stored in a Lets see an example of how these classes behave when stored in a
dictionary. First, lets store some dictionaries:: dictionary. First, lets store some dictionaries::
>>> import ZODB >>> import ZODB
>>> db = ZODB.DB(None) >>> db = ZODB.DB(None)
>>> conn1 = db.open() >>> 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