Skip to content
Projeler
Gruplar
Parçacıklar
Yardım
Yükleniyor...
Oturum aç / Kaydol
Gezinmeyi değiştir
C
cpython
Proje
Proje
Ayrıntılar
Etkinlik
Cycle Analytics
Depo (repository)
Depo (repository)
Dosyalar
Kayıtlar (commit)
Dallar (branch)
Etiketler
Katkıda bulunanlar
Grafik
Karşılaştır
Grafikler
Konular (issue)
0
Konular (issue)
0
Liste
Pano
Etiketler
Kilometre Taşları
Birleştirme (merge) Talepleri
0
Birleştirme (merge) Talepleri
0
CI / CD
CI / CD
İş akışları (pipeline)
İşler
Zamanlamalar
Grafikler
Paketler
Paketler
Wiki
Wiki
Parçacıklar
Parçacıklar
Üyeler
Üyeler
Collapse sidebar
Close sidebar
Etkinlik
Grafik
Grafikler
Yeni bir konu (issue) oluştur
İşler
Kayıtlar (commit)
Konu (issue) Panoları
Kenar çubuğunu aç
Batuhan Osman TASKAYA
cpython
Commits
8a61f499
Kaydet (Commit)
8a61f499
authored
Kas 13, 2002
tarafından
Andrew M. Kuchling
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Fill out the 'Porting' section
Add random.sample()
üst
e1172588
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
62 additions
and
2 deletions
+62
-2
whatsnew23.tex
Doc/whatsnew/whatsnew23.tex
+62
-2
No files found.
Doc/whatsnew/whatsnew23.tex
Dosyayı görüntüle @
8a61f499
...
...
@@ -943,7 +943,7 @@ property is O(lg~n). (See
\url
{
http://www.nist.gov/dads/HTML/priorityque.html
}
for more
information about the priority queue data structure.)
The
Python
\module
{
heapq
}
module provides
\function
{
heappush()
}
and
The
\module
{
heapq
}
module provides
\function
{
heappush()
}
and
\function
{
heappop()
}
functions for adding and removing items while
maintaining the heap property on top of some other mutable Python
sequence type. For example:
...
...
@@ -1000,6 +1000,31 @@ your character data handler and therefore faster performance. Setting
the parser object's
\member
{
buffer
_
text
}
attribute to
\constant
{
True
}
will enable buffering.
\item
The
\function
{
sample(
\var
{
population
}
,
\var
{
k
}
)
}
function was
added to the
\module
{
random
}
module.
\var
{
population
}
is a sequence
containing the elements of a population, and
\function
{
sample()
}
chooses
\var
{
k
}
elements from the population without replacing chosen
elements.
\var
{
k
}
can be any value up to
\code
{
len(
\var
{
population
}
)
}
.
For example:
\begin{verbatim}
>>> pop = range(6) ; pop
[0, 1, 2, 3, 4, 5]
>>> random.sample(pop, 3) # Choose three elements
[0, 4, 3]
>>> random.sample(pop, 6) # Choose all six elements
[4, 5, 0, 3, 2, 1]
>>> random.sample(pop, 6) # Choose six again
[4, 2, 3, 0, 5, 1]
>>> random.sample(pop, 7) # Can't choose more than six
Traceback (most recent call last):
File ``<stdin>'', line 1, in ?
File ``/home/amk/src/sf/python/dist/src/Lib/random.py'', line 396, in sample
raise ValueError, ``sample larger than population''
ValueError: sample larger than population
>>>
\end{verbatim}
\item
The
\module
{
readline
}
module also gained a number of new
functions:
\function
{
get
_
history
_
item()
}
,
\function
{
get
_
current
_
history
_
length()
}
, and
\function
{
redisplay()
}
.
...
...
@@ -1338,7 +1363,42 @@ under ``python -O'' in earlier versions of Python.
%======================================================================
\section
{
Porting to Python 2.3
}
XXX write this
This section lists changes that may actually require changes to your code:
\begin{itemize}
\item
\keyword
{
yield
}
is now always a keyword; if it's used as a
variable name in your code, a different name must be chosen.
\item
You can no longer disable assertions by assigning to
\code
{__
debug
__}
.
\item
Using
\code
{
None
}
as a variable name will now result in a
\exception
{
SyntaxWarning
}
warning.
\item
Names of extension types defined by the modules included with
Python now contain the module and a
\samp
{
.
}
in front of the type
name.
\item
For strings
\var
{
X
}
and
\var
{
Y
}
,
\code
{
\var
{
X
}
in
\var
{
Y
}}
now works
if
\var
{
X
}
is more than one character long.
\item
The Distutils
\function
{
setup()
}
function has gained various new
keyword arguments such as
\samp
{
depends
}
. Old versions of the
Distutils will abort if passed unknown keywords. The fix is to check
for the presence of the new
\function
{
get
_
distutil
_
options()
}
function
in your
\file
{
setup.py
}
if you want to only support the new keywords
with a version of the Distutils that supports them:
\begin{verbatim}
from distutils import core
kw =
{
'sources': 'foo.c', ...
}
if hasattr(core, 'get
_
distutil
_
options'):
kw['depends'] = ['foo.h']
ext = Extension(**kw)
\end{verbatim}
\end{itemize}
%======================================================================
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment