Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

max( str ) should be fast with PEP 393 #59431

Closed
vpython mannequin opened this issue Jun 29, 2012 · 3 comments
Closed

max( str ) should be fast with PEP 393 #59431

vpython mannequin opened this issue Jun 29, 2012 · 3 comments
Labels
interpreter-core (Objects, Python, Grammar, and Parser dirs) type-feature A feature request or enhancement

Comments

@vpython
Copy link
Mannequin

vpython mannequin commented Jun 29, 2012

BPO 15226
Nosy @loewis, @vstinner

Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

Show more details

GitHub fields:

assignee = None
closed_at = <Date 2012-06-30.10:12:06.635>
created_at = <Date 2012-06-29.19:53:25.041>
labels = ['interpreter-core', 'type-feature', 'invalid']
title = 'max( str ) should be fast with PEP 393'
updated_at = <Date 2012-06-30.10:12:06.634>
user = 'https://bugs.python.org/vpython'

bugs.python.org fields:

activity = <Date 2012-06-30.10:12:06.634>
actor = 'loewis'
assignee = 'none'
closed = True
closed_date = <Date 2012-06-30.10:12:06.635>
closer = 'loewis'
components = ['Interpreter Core']
creation = <Date 2012-06-29.19:53:25.041>
creator = 'v+python'
dependencies = []
files = []
hgrepos = []
issue_num = 15226
keywords = []
message_count = 3.0
messages = ['164351', '164352', '164362']
nosy_count = 3.0
nosy_names = ['loewis', 'vstinner', 'v+python']
pr_nums = []
priority = 'normal'
resolution = 'not a bug'
stage = None
status = 'closed'
superseder = None
type = 'enhancement'
url = 'https://bugs.python.org/issue15226'
versions = ['Python 3.3']

@vpython
Copy link
Mannequin Author

vpython mannequin commented Jun 29, 2012

This is stupid code, but it should be faster with PEP-393 than before, should it not?

str = ' ' * 5000000 + "this is really a string example....wow!!!";
for ix in range( 9000 ):
z = max(str)
print("Max character: " + max(str))

While the new C API seems to support quickly finding the max character in a string, Python code does not benefit.

@vpython vpython mannequin added the interpreter-core (Objects, Python, Grammar, and Parser dirs) label Jun 29, 2012
@loewis
Copy link
Mannequin

loewis mannequin commented Jun 29, 2012

What the C code finds quickly (in constant time) is that the maximum is <=127. Most code doesn't know (and doesn't care) what the actual maximum is. So I see no bug here.

@vpython
Copy link
Mannequin Author

vpython mannequin commented Jun 29, 2012

Ah, so then it would require a new API to make the Python code as smart as the C code, max is too general.

bpo-15016 is an example of Python code that could benefit from knowing in constant time if the string contained only characters < 128, or if the string contained only characters < 256... a three way decision.

@vpython vpython mannequin added the type-feature A feature request or enhancement label Jun 29, 2012
@loewis loewis mannequin closed this as completed Jun 30, 2012
@loewis loewis mannequin added the invalid label Jun 30, 2012
@ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
interpreter-core (Objects, Python, Grammar, and Parser dirs) type-feature A feature request or enhancement
Projects
None yet
Development

No branches or pull requests

0 participants