[issue31594] Make bytes and bytearray maketrans accept dictionaries as first argument as it's done in str

2021-10-25 Thread Irit Katriel


Change by Irit Katriel :


--
resolution:  -> rejected
stage:  -> resolved
status: open -> closed
type: behavior -> enhancement

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue31594] Make bytes and bytearray maketrans accept dictionaries as first argument as it's done in str

2017-09-29 Thread Terry J. Reedy

Terry J. Reedy  added the comment:

Consistency between bytes and strings is not much of a concern here, or the 
change would have been make for bytes when it was made for strings.  I would 
not approve the request without knowing who chose not to and why.

I think an example like
t = bytes.maketrans(
b'ABCDEVGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz',
b'vcccvcccvcvcvcscscvcccvcccvcvcvcscsc')
is *much* better as it is than as a dict.

--
nosy: +terry.reedy

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue31594] Make bytes and bytearray maketrans accept dictionaries as first argument as it's done in str

2017-09-26 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

Inconsistency is a weak argument. It itself is not enough to add a new feature. 
str.translate() accepts a mapping instead of a string (as it would be for 
consistency with bytes.translate()) because it would be inconvenient to provide 
a 1114112-character string. str.maketrans() just compile a mapping in the 
optimized representation, because using a general mapping is not very efficient.

A bytes object of length 256 already is the most efficient representation of 
the translation table for bytes. And you can create it from a mapping in Python:

def mymaketrans(mapping):
table = bytearray(range(256))
for x, y in mapping.items():
table[x] = y
return table

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue31594] Make bytes and bytearray maketrans accept dictionaries as first argument as it's done in str

2017-09-26 Thread Oleksandr Suvorov

Oleksandr Suvorov added the comment:

This change requested just because I find it inconsistent and passing
translation as key-value is much easier to read rather than two lists.
When translation table gets bigger than 10 pairs it gets annoying to match
in the head between from and to while reading it.
Could be marked as minor.
--_

> Python tracker 
> 
> ___
>

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue31594] Make bytes and bytearray maketrans accept dictionaries as first argument as it's done in str

2017-09-26 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

Why do you need this functionality?

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue31594] Make bytes and bytearray maketrans accept dictionaries as first argument as it's done in str

2017-09-26 Thread Oleksandr Suvorov

Oleksandr Suvorov added the comment:

str.maketrans in python3 is able to accept just one argument which is a
mapping of translations.
While bytearray and bytes are still using only old way where you should
pass two iterables from and to.

static str.maketrans(x [,y [,z]])
static bytes.maketrans(from, to)
static bytearray.maketrans(from, to)

On Tue, Sep 26, 2017 at 6:12 PM, Serhiy Storchaka 
wrote:

>
> New submission from Serhiy Storchaka:
>
> Could you please provide more information? What the problem you want to
> solve?
>
> --
> nosy: +serhiy.storchaka
>
> ___
> Python tracker 
> 
> ___
>

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue31594] Make bytes and bytearray maketrans accept dictionaries as first argument as it's done in str

2017-09-26 Thread Serhiy Storchaka

New submission from Serhiy Storchaka:

Could you please provide more information? What the problem you want to solve?

--
nosy: +serhiy.storchaka

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue31594] Make bytes and bytearray maketrans accept dictionaries as first argument as it's done in str

2017-09-26 Thread Oleksandr Suvorov

Changes by Oleksandr Suvorov :


--
components: Interpreter Core
nosy: soosleek
priority: normal
severity: normal
status: open
title: Make bytes and bytearray maketrans accept dictionaries as first argument 
as it's done in str
type: behavior
versions: Python 3.7

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com