[issue40344] Programming FAQ about "What is the most efficient way to concatenate many strings together?" -- Improving the example

2020-05-24 Thread Andy Lester


Andy Lester  added the comment:

I'd also like to suggest that the question not be "most efficient" but 
"fastest".  I don't think it should treat "efficient" and "fast" as synonyms. 
"Efficient" can mean things other than execution speed, such as memory usage, 
or programmer time.  Are there space/time considerations besides execution 
time?  What if the user has a huge list and wants to use as little new 
allocated RAM as possible?

I understand that it's immediately after the "How do I speed up my program?" 
question, and I think it's worth considering making the question more explicit 
what kind of efficiency we're talking about.

--

___
Python tracker 

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



[issue40344] Programming FAQ about "What is the most efficient way to concatenate many strings together?" -- Improving the example

2020-05-24 Thread Batuhan Taskaya


Change by Batuhan Taskaya :


--
pull_requests:  -19625

___
Python tracker 

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



[issue40344] Programming FAQ about "What is the most efficient way to concatenate many strings together?" -- Improving the example

2020-05-24 Thread Batuhan Taskaya


Change by Batuhan Taskaya :


--
pull_requests: +19625
pull_request: https://github.com/python/cpython/pull/20360

___
Python tracker 

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



[issue40344] Programming FAQ about "What is the most efficient way to concatenate many strings together?" -- Improving the example

2020-05-24 Thread Batuhan Taskaya


Change by Batuhan Taskaya :


--
pull_requests:  -19624

___
Python tracker 

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



[issue40344] Programming FAQ about "What is the most efficient way to concatenate many strings together?" -- Improving the example

2020-05-24 Thread Batuhan Taskaya


Change by Batuhan Taskaya :


--
keywords: +patch
pull_requests: +19624
stage:  -> patch review
pull_request: https://github.com/python/cpython/pull/20360

___
Python tracker 

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



[issue40344] Programming FAQ about "What is the most efficient way to concatenate many strings together?" -- Improving the example

2020-04-28 Thread Batuhan Taskaya


Change by Batuhan Taskaya :


--
stage: patch review -> 

___
Python tracker 

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



[issue40344] Programming FAQ about "What is the most efficient way to concatenate many strings together?" -- Improving the example

2020-04-28 Thread Batuhan Taskaya


Change by Batuhan Taskaya :


--
keywords:  -patch

___
Python tracker 

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



[issue40344] Programming FAQ about "What is the most efficient way to concatenate many strings together?" -- Improving the example

2020-04-28 Thread Batuhan Taskaya


Change by Batuhan Taskaya :


--
pull_requests:  -19105

___
Python tracker 

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



[issue40344] Programming FAQ about "What is the most efficient way to concatenate many strings together?" -- Improving the example

2020-04-28 Thread Batuhan Taskaya


Change by Batuhan Taskaya :


--
pull_requests: +19105
pull_request: https://github.com/python/cpython/pull/19782

___
Python tracker 

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



[issue40344] Programming FAQ about "What is the most efficient way to concatenate many strings together?" -- Improving the example

2020-04-28 Thread Batuhan Taskaya


Batuhan Taskaya  added the comment:

Sorry for the noise, wrong issue (thought 344, but actually was 334)

--

___
Python tracker 

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



[issue40344] Programming FAQ about "What is the most efficient way to concatenate many strings together?" -- Improving the example

2020-04-28 Thread Batuhan Taskaya


Change by Batuhan Taskaya :


--
pull_requests:  -19103

___
Python tracker 

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



[issue40344] Programming FAQ about "What is the most efficient way to concatenate many strings together?" -- Improving the example

2020-04-28 Thread Batuhan Taskaya


Change by Batuhan Taskaya :


--
keywords: +patch
nosy: +BTaskaya
nosy_count: 4.0 -> 5.0
pull_requests: +19103
stage:  -> patch review
pull_request: https://github.com/python/cpython/pull/19782

___
Python tracker 

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



[issue40344] Programming FAQ about "What is the most efficient way to concatenate many strings together?" -- Improving the example

2020-04-20 Thread Raymond Hettinger


Raymond Hettinger  added the comment:

Your contributions are welcome.

--

___
Python tracker 

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



[issue40344] Programming FAQ about "What is the most efficient way to concatenate many strings together?" -- Improving the example

2020-04-20 Thread Andy Lester


Change by Andy Lester :


--
nosy: +petdance

___
Python tracker 

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



[issue40344] Programming FAQ about "What is the most efficient way to concatenate many strings together?" -- Improving the example

2020-04-20 Thread Dominik V.


Dominik V.  added the comment:

It was not my intention to disturb the traffic on the bug tracker. My apologies 
if that caused any trouble. I also thought only people subscribed to the 
indicated topic (e.g. "Documentation") would receive a notification.

The docs pages mention that for enhancement proposals one should submit a bug 
report on the tracker:

> If you find a bug in this documentation or would like to propose an 
> improvement, please submit a bug report on the tracker 
> (https://docs.python.org/3/bugs.html).

I do care about the quality of Python's documentation and I think it could be 
improved in these cases. Often it is newcomers who consult these pages and they 
might be irritated by the mentioned parts.

I see how it would be distracting to include a more complex real world example, 
but using an example which performs apparently superfluous steps without any 
additional comment might seem strange. More experienced users probably won't 
need such an example at all. In addition it might make people falsely belief 
that `str.join` expects a list of strings rather than any iterable, and hence 
the explicit construction of the list.

--

___
Python tracker 

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



[issue40344] Programming FAQ about "What is the most efficient way to concatenate many strings together?" -- Improving the example

2020-04-20 Thread Raymond Hettinger


Raymond Hettinger  added the comment:

Dominik, can you please limit your tracker issues to a handful on entries that 
you really care about?  This is turning into a stream of consciousness dump 
onto our tracker.  You really don't need to rewrite every entry you see, 
especially when we haven't had user complaints about the existing entries.

Also, it seems to me that you're missing the point of the simplified examples 
in the docs.  Yes, of course, the for-loop in chunks is superfluous; however, 
that for-loop is very common pattern, but it typically does other work in the 
loop.  For example:

blocks = []
while True:
block = s.recv(4096)
if not block:
break
blocks.append(block)
page = b''.join(blocks)

The problem with that example is that it shifts focus to tcp clients rather 
than the core topic to how to join strings.

--
nosy: +rhettinger

___
Python tracker 

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



[issue40344] Programming FAQ about "What is the most efficient way to concatenate many strings together?" -- Improving the example

2020-04-20 Thread Dominik V.


Dominik V.  added the comment:

Here's the link to the relevant section: 
https://docs.python.org/3/faq/programming.html#what-is-the-most-efficient-way-to-concatenate-many-strings-together

--

___
Python tracker 

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



[issue40344] Programming FAQ about "What is the most efficient way to concatenate many strings together?" -- Improving the example

2020-04-20 Thread Dominik V.


New submission from Dominik V. :

The section mentions the usage of `str.join` and contains the following example:

chunks = []
for s in my_strings:
chunks.append(s)
result = ''.join(chunks)

Since `join` accepts any iterable the creation of the `chunks` list in a for 
loop is superfluous. If people just copy & paste from this FAQ they'll even end 
up with less performant code.

The example could be improved by providing an example list such as:

strings = ['spam', 'ham', 'eggs']
meal = ', '.join(strings)

Arguably this isn't a particularly long list of strings, so one more example 
could be added using e.g. `range(100)`:

numbers = ','.join(str(x) for x in range(100))

This also emphasizes the fact that `join` takes any iterable rather than just 
lists.

--
assignee: docs@python
components: Documentation
messages: 366887
nosy: Dominik V., docs@python
priority: normal
severity: normal
status: open
title: Programming FAQ about "What is the most efficient way to concatenate 
many strings together?" -- Improving the example
type: enhancement
versions: Python 3.8, Python 3.9

___
Python tracker 

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