- 论坛徽章:
- 0
|
我抄帮助文档的:
XRange Type
The range type is an immutable sequence which is commonly used for looping. The advantage of the range type is that an range object will always take the same amount of memory, no matter the size of the range it represents. There are no consistent performance advantages.
XRange objects have very little behavior: they only support indexing, iteration, and the len() function
我抄Python In A Nutshell的:
Returns a read-only sequence object whose items are integers in arithmetic progression. The arguments are the same as for range, covered in "range". While range creates and returns a normal list object, xrange returns a sequence object of a special type, mostly meant to be used in a for statement (you can index that object, but you cannot slice it). xrange consumes less memory than range for this specific, frequent use, in which all you need to do is loop on an arithmetic progression. However, xrange has a slightly higher overhead than range for the loop itself. Overall, performance differences between xrange and range are normally small and not worth worrying about. |
|