Commit Graph

29202 Commits

Author SHA1 Message Date
Raymond Hettinger
79b5cf1129 Mention the optimization of list.extend(). 2004-02-17 10:46:32 +00:00
Fred Drake
70a30e8c94 markup correction 2004-02-17 04:17:36 +00:00
Anthony Baxter
5d7c06720d Make socketmodule compile again on a modern Linux (that supports Bluetooth).
The Bluetooth code was obviously never tested on Linux.
2004-02-16 05:35:28 +00:00
Neal Norwitz
94f1d71d70 Fix docstrings to mention the correct function 2004-02-16 01:26:34 +00:00
Martin v. Löwis
d3c810ed31 Patch #892673: Replace /usr/local/bin/python with
/usr/bin/env python'%{binsuffix}
Backported to 2.3.
2004-02-15 21:27:03 +00:00
Martin v. Löwis
a79449e7a2 Patch #711838: Allow non-anonymous ftp urls in urllib2.
Backported to 2.3.
2004-02-15 21:19:18 +00:00
Martin v. Löwis
d3f4a1a00a Patch #893566: Document that tp_dealloc may be called from any thread. 2004-02-15 21:01:17 +00:00
Martin v. Löwis
7db04e7c48 Patch #817379: Allow for absolute ftp paths.
Backported to 2.3.
2004-02-15 20:51:39 +00:00
Neil Schemenauer
32d23c9264 Fix typo. 2004-02-15 16:43:20 +00:00
Raymond Hettinger
fa7b9d8255 * Moved the responsibility for emptying the previous list from list_fill
to list_init.

* Replaced the code in list_extend with the superior code from list_fill.

* Eliminated list_fill.

Results:

* list.extend() no longer creates an intermediate tuple except to handle
  the special case of x.extend(x).  The saves memory and time.

* list.extend(x) runs
    about the same x is a list or tuple,
    a little faster when x is an iterable not defining __len__, and
    twice as fast when x is an iterable defining __len__.

* the code is about 15 lines shorter and no longer duplicates
  functionality.
2004-02-15 04:06:39 +00:00
Raymond Hettinger
90a39bf12c Refactor list_extend() and list_fill() for gains in code size, memory
utilization, and speed:

* Moved the responsibility for emptying the previous list from list_fill
  to list_init.

* Replaced the code in list_extend with the superior code from list_fill.

* Eliminated list_fill.

Results:

* list.extend() no longer creates an intermediate tuple except to handle
  the special case of x.extend(x).  The saves memory and time.

* list.extend(x) runs
    5 to 10% faster when x is a list or tuple
    15% faster when x is an iterable not defining __len__
    twice as fast when x is an iterable defining __len__

* the code is about 15 lines shorter and no longer duplicates
  functionality.
2004-02-15 03:57:00 +00:00
Raymond Hettinger
ab517d2eac Fine tune the speed/space trade-off for overallocating small lists.
The Py2.3 approach overallocated small lists by up to 8 elements.
The last checkin would limited this to one but slowed down (by 20 to 30%)
the creation of small lists between 3 to 8 elements.

This tune-up balances the two, limiting overallocation to 3 elements
(significantly reducing space consumption from Py2.3) and running faster
than the previous checkin.

The first part of the growth pattern (0, 4, 8, 16) neatly meshes with
allocators that trigger data movement only when crossing a power of two
boundary.  Also, then even numbers mesh well with common data alignments.
2004-02-14 18:34:46 +00:00
Raymond Hettinger
2731ae4d6d Fix missing return value. Spotted by Neal Norwitz 2004-02-14 03:07:21 +00:00
Gustavo Niemeyer
601b963be0 - Fixing annoying warnings. 2004-02-14 00:31:13 +00:00
Gustavo Niemeyer
a6e436e4b4 - Fixed #853061: allow BZ2Compressor.compress() to receive an empty string
as parameter.
2004-02-14 00:02:45 +00:00
Raymond Hettinger
238b267bf6 Lists are measured in elements not bytes. 2004-02-13 21:50:27 +00:00
Fred Drake
55cf434735 further testing indicates that the simplified version of the test
(re-using an existing test object class) no longer triggered the
original segfault when the fix was backed out; restoring the local
test object class to make the test effective

the assignment of the ref created at the end does not affect the test,
since the segfault happended before weakref.ref() returned; removing
the assignment
2004-02-13 19:21:57 +00:00
Raymond Hettinger
7a6d297bda * Note list optimizations
* Move an example out of a comment.
2004-02-13 19:00:07 +00:00
Raymond Hettinger
cb3e580ebc Optimize list.pop() for the common special case of popping off the end.
More than doubles its speed.
2004-02-13 18:36:31 +00:00
Raymond Hettinger
4bb9540dd6 * Optimized list appends and pops by making fewer calls the underlying system
realloc().  This is achieved by tracking the overallocation size in a new
  field and using that information to skip calls to realloc() whenever
  possible.

* Simplified and tightened the amount of overallocation.  For larger lists,
  this overallocates by 1/8th (compared to the previous scheme which ranged
  between 1/4th to 1/32nd over-allocation).  For smaller lists (n<6), the
  maximum overallocation is one byte (formerly it could be upto eight bytes).
  This saves memory in applications with large numbers of small lists.

* Eliminated the NRESIZE macro in favor of a new, static list_resize function
  that encapsulates the resizing logic.  Coverting this back to macro would
  give a small (under 1%) speed-up.  This was too small to warrant the loss
  of readability, maintainability, and de-coupling.

* Some functions using NRESIZE had grown unnecessarily complex in their
  efforts to bend to the macro's calling pattern.  With the new list_resize
  function in place, those other functions could be simplified.  That is
  being saved for a separate patch.

* The ob_item==NULL check could be eliminated from the new list_resize
  function.  This would entail finding each piece of code that sets ob_item
  to NULL and adding a new line to invalidate the overallocation tracking
  field.  Rather than impose a new requirement on other pieces of list code,
  it was preferred to leave the NULL check in place and retain the benefits
  of decoupling, maintainability and information hiding (only PyList_New()
  and list_sort() need to know about the new field).  This approach also
  reduces the odds of breaking an extension module.

(Collaborative effort by Raymond Hettinger, Hye-Shik Chang, Tim Peters,
 and Armin Rigo.)
2004-02-13 11:36:39 +00:00
Hye-Shik Chang
4a8d42f73f We have cp932 support in standard distribution now. And there's now
no major codepages unsupported by Python, so remove the eg. case.
2004-02-13 07:14:13 +00:00
Fred Drake
61dafcb6ca use existing test object instead of defining a new class 2004-02-12 19:30:17 +00:00
Fred Drake
ce3caf2e7a minor markup improvements 2004-02-12 18:13:12 +00:00
Walter Dörwald
70a6b49821 Replace backticks with repr() or "%r"
From SF patch #852334.
2004-02-12 17:35:32 +00:00
Michael W. Hudson
ecfeb7f095 This is my patch #876198 plus a NEWS entry and a header frob.
Remove the ability to use (from C) arbitrary objects supporting the
read buffer interface as the co_code member of code objects.
2004-02-12 15:28:27 +00:00
Fred Drake
e6ed33a6b3 fix minor markup error: \code{for} --> \keyword{for} 2004-02-12 14:35:18 +00:00
Raymond Hettinger
b1e5b50531 SF 895560: minor typo 2004-02-12 09:50:42 +00:00
Skip Montanaro
f3938fd029 need to initialize ob_type slot at run-time, at least on cygwin 2004-02-10 20:27:40 +00:00
Fred Drake
29f5933fcb add support for \e to the {alltt} environment 2004-02-10 18:30:22 +00:00
Neal Norwitz
d311f1fb9b SF #894428, fix typo 2004-02-10 18:07:16 +00:00
Skip Montanaro
7befb9966e remove support for missing ANSI C header files (limits.h, stddef.h, etc). 2004-02-10 16:50:21 +00:00
Skip Montanaro
05eb40128e Fix indentation error in testGetServByName and rewrite loop to avoid clumsy
sentinel variable
2004-02-10 15:51:15 +00:00
Raymond Hettinger
029dba5a40 Make reversed() transparent with respect to length. 2004-02-10 09:33:39 +00:00
Raymond Hettinger
5cab2e3a88 Give itertools.repeat() a length method. 2004-02-10 09:25:40 +00:00
Fred Drake
27da291b2c the \file macro is no longer a good example of where \e can't be used 2004-02-09 21:00:29 +00:00
Fred Drake
52feb81932 support \e in \file and \filenq; this is useful for Windows paths 2004-02-09 20:58:08 +00:00
Andrew M. Kuchling
fd0e494c98 Minor edits 2004-02-09 13:23:34 +00:00
Thomas Heller
8178a22e20 Documentation for PyDescr_NewClassMethod was missing - here's at least
the function prototype.

Already backported to release23-maint.
2004-02-09 10:47:11 +00:00
Raymond Hettinger
5de33786a9 SF patch #892821: example for urllib2 has SyntaxError
(Contributed by George Yoshida.)
2004-02-08 20:25:01 +00:00
Raymond Hettinger
3fd977964a Fix misspelled name. 2004-02-08 20:18:26 +00:00
Raymond Hettinger
7820554c2c Fix typo 2004-02-08 20:05:40 +00:00
Raymond Hettinger
a72169871d SF patch #884022: dynamic execution profiling vs opcode prediction
(Contributed by Andrew I MacIntyre.)

disables opcode prediction when dynamic execution
profiling is in effect, so the profiling counters at
the top of the main interpreter loop in eval_frame()
are updated for each opcode.
2004-02-08 19:59:27 +00:00
Raymond Hettinger
ce9b4714ef SF patch #880552: Fix typo in usage message(prechm.py)
(Contributed by George Yoshida.)

* Also convert tabs to spaces.
2004-02-08 19:24:18 +00:00
Raymond Hettinger
b32e640489 SF patch #875689: >100k alloc wasted on startup
(Contributed by Mike Pall.)

Make sure fill_free_list() is called only once rather than 106 times
when pre-allocating small ints.
2004-02-08 18:54:37 +00:00
Raymond Hettinger
4c9800d663 SF bug #892854: typo in textwrap doc page
(Reported by Drew Perttula.)
2004-02-08 18:09:32 +00:00
Raymond Hettinger
3dc3484ac8 SF bug #892492: Multiple close() for asyncore.dispatcher.
(Contributed by Alexey Klimkin.)

Don't keep the file descriptor after the channel is deleted.
2004-02-08 11:32:50 +00:00
Raymond Hettinger
204b000610 Revert improvement to list.append() checked in before it was ready. 2004-02-08 11:08:52 +00:00
Raymond Hettinger
06353f76be Let reversed() work with itself. 2004-02-08 10:49:42 +00:00
Jim Fulton
8a1a594590 Fixed a bug in object.__reduce_ex__ (reduce_2) when using protocol
2.  Failure to clear the error when attempts to get the __getstate__
  attribute fail caused intermittent errors and odd behavior.
2004-02-08 04:21:26 +00:00
Raymond Hettinger
ee33b27ef0 Make deque.rotate() smarter. Beef-up related tests. 2004-02-08 04:05:26 +00:00