summaryrefslogtreecommitdiffstats
path: root/Doc/whatsnew
diff options
context:
space:
mode:
authorAndrew M. Kuchling <amk@amk.ca>2006-05-26 18:41:18 (GMT)
committerAndrew M. Kuchling <amk@amk.ca>2006-05-26 18:41:18 (GMT)
commitafe6598732b4a8eee9f2d746080cd0bb28f17704 (patch)
tree499419ac0166eb812ef6aeaa6256c1faec0eaed3 /Doc/whatsnew
parentd05e5468501ff572a55349a584a28d09f9d7abb3 (diff)
downloadcpython-afe6598732b4a8eee9f2d746080cd0bb28f17704.zip
cpython-afe6598732b4a8eee9f2d746080cd0bb28f17704.tar.gz
cpython-afe6598732b4a8eee9f2d746080cd0bb28f17704.tar.bz2
Add rpartition() and path caching
Diffstat (limited to 'Doc/whatsnew')
-rw-r--r--Doc/whatsnew/whatsnew25.tex21
1 files changed, 18 insertions, 3 deletions
diff --git a/Doc/whatsnew/whatsnew25.tex b/Doc/whatsnew/whatsnew25.tex
index 5f8848a..1b228a2 100644
--- a/Doc/whatsnew/whatsnew25.tex
+++ b/Doc/whatsnew/whatsnew25.tex
@@ -1042,15 +1042,22 @@ print d[1], d[2] # Prints 1, 2
print d[3], d[4] # Prints 0, 0
\end{verbatim}
-\item Both 8-bit and Unicode strings have a new \method{partition(sep)} method.
+\item Both 8-bit and Unicode strings have new \method{partition(sep)}
+and \method{rpartition(sep)} methods that simplify a common use case.
The \method{find(S)} method is often used to get an index which is
then used to slice the string and obtain the pieces that are before
-and after the separator. \method{partition(sep)} condenses this
+and after the separator.
+
+\method{partition(sep)} condenses this
pattern into a single method call that returns a 3-tuple containing
the substring before the separator, the separator itself, and the
substring after the separator. If the separator isn't found, the
first element of the tuple is the entire string and the other two
-elements are empty. Some examples:
+elements are empty. \method{rpartition(sep)} also returns a 3-tuple
+but starts searching from the end of the string; the \samp{r} stands
+for 'reverse'.
+
+Some examples:
\begin{verbatim}
>>> ('http://www.python.org').partition('://')
@@ -1059,6 +1066,8 @@ elements are empty. Some examples:
(u'Subject', u':', u' a quick question')
>>> ('file:/usr/share/doc/index.html').partition('://')
('file:/usr/share/doc/index.html', '', '')
+>>> 'www.python.org'.rpartition('.')
+('www.python', '.', 'org')
\end{verbatim}
(Implemented by Fredrik Lundh following a suggestion by Raymond Hettinger.)
@@ -1192,6 +1201,12 @@ Frame objects are also slightly smaller, which may improve cache locality
and reduce memory usage a bit. (Contributed by Neal Norwitz.)
% Patch 1337051
+\item Importing now caches the paths tried, recording whether
+they exist or not so that the interpreter makes fewer
+\cfunction{open()} and \cfunction{stat()} calls on startup.
+(Contributed by Martin von~L\"owis and Georg Brandl.)
+% Patch 921466
+
\end{itemize}
The net result of the 2.5 optimizations is that Python 2.5 runs the