Movatterモバイル変換


[0]ホーム

URL:


Following system colour schemeSelected dark colour schemeSelected light colour scheme

Python Enhancement Proposals

PEP 332 – Byte vectors and String/Unicode Unification

PEP 332 – Byte vectors and String/Unicode Unification

Author:
Skip Montanaro <skip at pobox.com>
Status:
Rejected
Type:
Standards Track
Created:
11-Aug-2004
Python-Version:
2.5
Post-History:


Table of Contents

Abstract

This PEP outlines the introduction of a rawbytes sequence objectand the unification of the currentstr andunicode objects.

Rejection Notice

This PEP is rejected in this form. The author has expressed lack oftime to continue to shepherd it, and discussion on python-dev hasmoved to a slightly different proposal which will (eventually) bewritten up as a new PEP. See the thread starting athttps://mail.python.org/pipermail/python-dev/2006-February/060930.html.

Rationale

Python’s current string objects are overloaded. They serve both tohold ASCII and non-ASCII character data and to also hold sequences ofraw bytes which have no reasonable interpretation as displayablecharacter sequences. This overlap hasn’t been a big problem in thepast, but as Python moves closer to requiring source code to beproperly encoded, the use of strings to represent raw byte sequenceswill be more problematic. In addition, as Python’s Unicode supporthas improved, it’s easier to consider strings as ASCII-encoded Unicodeobjects.

Proposed Implementation

The number in parentheses indicates the Python version in which thefeature will be introduced.

  • Add abytes builtin which is just a synonym forstr. (2.5)
  • Add ab"..." string literal which is equivalent to raw stringliterals, with the exception that values which conflict with thesource encoding of the containing file not generate warnings. (2.5)
  • Warn about the use of variables named “bytes”. (2.5 or 2.6)
  • Introduce abytes builtin which refers to a sequence distinctfrom thestr type. (2.6)
  • Makestr a synonym forunicode. (3.0)

Bytes Object API

TBD.

Issues

  • Can this be accomplished before Python 3.0?
  • Shouldbytes objects be mutable or immutable? (Guido seems tolike them to be mutable.)

Copyright

This document has been placed in the public domain.


Source:https://github.com/python/peps/blob/main/peps/pep-0332.rst

Last modified:2025-02-01 08:59:27 GMT


[8]ページ先頭

©2009-2026 Movatter.jp