diff options
author | Georg Brandl <georg@python.org> | 2009-10-27 20:23:20 (GMT) |
---|---|---|
committer | Georg Brandl <georg@python.org> | 2009-10-27 20:23:20 (GMT) |
commit | 1e8cbe36cc2455296d38f927d1ab54b93d894881 (patch) | |
tree | 2ed1df8c9dd684a27793897c2cf542cf0111e269 /Doc/faq/library.rst | |
parent | cb7cb247b32acdd0816663d35ad51057a8571894 (diff) | |
download | cpython-1e8cbe36cc2455296d38f927d1ab54b93d894881.zip cpython-1e8cbe36cc2455296d38f927d1ab54b93d894881.tar.gz cpython-1e8cbe36cc2455296d38f927d1ab54b93d894881.tar.bz2 |
Merged revisions 75393,75416,75581,75609,75615 via svnmerge from
svn+ssh://svn.python.org/python/branches/py3k
................
r75393 | georg.brandl | 2009-10-13 18:55:12 +0200 (Di, 13 Okt 2009) | 1 line
Update module names in references in the FAQ.
................
r75416 | georg.brandl | 2009-10-14 20:46:15 +0200 (Mi, 14 Okt 2009) | 1 line
#7129: add missing function.
................
r75581 | georg.brandl | 2009-10-21 09:17:48 +0200 (Mi, 21 Okt 2009) | 9 lines
Merged revisions 75580 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r75580 | georg.brandl | 2009-10-21 09:15:59 +0200 (Mi, 21 Okt 2009) | 1 line
#7170: fix explanation about non-weakrefable builtin types.
........
................
r75609 | georg.brandl | 2009-10-22 17:16:26 +0200 (Do, 22 Okt 2009) | 1 line
#7137: fix makefile() documentation to match the new parameters.
................
r75615 | georg.brandl | 2009-10-22 18:08:10 +0200 (Do, 22 Okt 2009) | 1 line
#6927: fix wrong word.
................
Diffstat (limited to 'Doc/faq/library.rst')
-rw-r--r-- | Doc/faq/library.rst | 24 |
1 files changed, 10 insertions, 14 deletions
diff --git a/Doc/faq/library.rst b/Doc/faq/library.rst index d977c77..db69449 100644 --- a/Doc/faq/library.rst +++ b/Doc/faq/library.rst @@ -232,11 +232,9 @@ Threads How do I program using threads? ------------------------------- -.. XXX it's _thread in py3k - -Be sure to use the :mod:`threading` module and not the :mod:`thread` module. +Be sure to use the :mod:`threading` module and not the :mod:`_thread` module. The :mod:`threading` module builds convenient abstractions on top of the -low-level primitives provided by the :mod:`thread` module. +low-level primitives provided by the :mod:`_thread` module. Aahz has a set of slides from his threading tutorial that are helpful; see http://starship.python.net/crew/aahz/OSCON2001/. @@ -280,7 +278,7 @@ A simple fix is to add a tiny sleep to the start of the run function:: Instead of trying to guess how long a :func:`time.sleep` delay will be enough, it's better to use some kind of semaphore mechanism. One idea is to use the -:mod:`Queue` module to create a queue object, let each thread append a token to +:mod:`queue` module to create a queue object, let each thread append a token to the queue when it finishes, and let the main thread read as many tokens from the queue as there are threads. @@ -288,8 +286,8 @@ queue as there are threads. How do I parcel out work among a bunch of worker threads? --------------------------------------------------------- -Use the :mod:`Queue` module to create a queue containing a list of jobs. The -:class:`~Queue.Queue` class maintains a list of objects with ``.put(obj)`` to +Use the :mod:`queue` module to create a queue containing a list of jobs. The +:class:`~queue.Queue` class maintains a list of objects with ``.put(obj)`` to add an item to the queue and ``.get()`` to return an item. The class will take care of the locking necessary to ensure that each job is handed out exactly once. @@ -777,11 +775,10 @@ Are there any interfaces to database packages in Python? Yes. -.. XXX remove bsddb in py3k, fix other module names - -Python 2.3 includes the :mod:`bsddb` package which provides an interface to the -BerkeleyDB library. Interfaces to disk-based hashes such as :mod:`DBM <dbm>` -and :mod:`GDBM <gdbm>` are also included with standard Python. +Interfaces to disk-based hashes such as :mod:`DBM <dbm.ndbm>` and :mod:`GDBM +<dbm.gnu>` are also included with standard Python. There is also the +:mod:`sqlite3` module, which provides a lightweight disk-based relational +database. Support for most relational databases is available. See the `DatabaseProgramming wiki page @@ -794,8 +791,7 @@ How do you implement persistent objects in Python? The :mod:`pickle` library module solves this in a very general way (though you still can't store things like open files, sockets or windows), and the :mod:`shelve` library module uses pickle and (g)dbm to create persistent -mappings containing arbitrary Python objects. For better performance, you can -use the :mod:`cPickle` module. +mappings containing arbitrary Python objects. A more awkward way of doing things is to use pickle's little sister, marshal. The :mod:`marshal` module provides very fast ways to store noncircular basic |