[issue36049] No __repr__() for queue.PriorityQueue and queue.LifoQueue

2019-02-20 Thread Zahash Z
New submission from Zahash Z : There is no __repr__() method for the PriorityQueue class and LifoQueue class in the queue.py file This makes it difficult to check the elements of the queue. -- messages: 336053 nosy: Zahash Z priority: normal severity: normal status: open title: No __r

[issue36049] No __repr__() for queue.PriorityQueue and queue.LifoQueue

2019-02-20 Thread Stéphane Wirtel
Stéphane Wirtel added the comment: but the __repr__ would have a limitation because you can't show all the elements from your queue, for example, if your queue contains 1000 items, the __repr__ will show the total items or just the ten first ones? We need a compromise for that. -- no

[issue36049] No __repr__() for queue.PriorityQueue and queue.LifoQueue

2019-02-20 Thread Stéphane Wirtel
Stéphane Wirtel added the comment: and there is an other issue, we need to iterate over the elements of the deque() :/ not really performant, just for a repr(). for my part, -1 if we have to iterate over the elements. -- ___ Python tracker

[issue36049] No __repr__() for queue.PriorityQueue and queue.LifoQueue

2019-02-20 Thread Windson Yang
Windson Yang added the comment: Hello, Zahash Z. May I ask what is your expected behavior for the return value of __repr__() from PriorityQueue. I'm agreed with Stéphane Wirtel, I don't think returning all the items would be a good idea, maybe we can improve it in another way. For instance, r

[issue36049] No __repr__() for queue.PriorityQueue and queue.LifoQueue

2019-02-20 Thread Stéphane Wirtel
Stéphane Wirtel added the comment: >>> from collections import deque >>> d = deque() >>> d.append('j') >>> d.appendleft('f') >>> d deque(['f', 'j']) >>> repr(d) "deque(['f', 'j'])" Maybe there is a solution, in the code of deque_repr, we convert the deque to a list. We could do the same thing

[issue36049] No __repr__() for queue.PriorityQueue and queue.LifoQueue

2019-02-20 Thread Stéphane Wirtel
Stéphane Wirtel added the comment: For this script, you could have the following output: from queue import Queue q = Queue() print(repr(q)) q.put('a') print(repr(q)) q.put('b') print(repr(q)) q.put('c') print(repr(q)) Queue() Queue('a') Queue('a','b') Queue('a'...'c') -- ___

[issue36049] No __repr__() for queue.PriorityQueue and queue.LifoQueue

2019-02-20 Thread Stéphane Wirtel
Stéphane Wirtel added the comment: New output for Queue, PriorityQueue and LifoQueue Queue() Queue('a') Queue('a','b') Queue('a'...'c') PriorityQueue() PriorityQueue('a') PriorityQueue('a','b') PriorityQueue('a'...'c') LifoQueue() LifoQueue('a') LifoQueue('a','b') LifoQueue('a'...'c') ---

[issue36049] No __repr__() for queue.PriorityQueue and queue.LifoQueue

2019-02-20 Thread Stéphane Wirtel
Change by Stéphane Wirtel : -- keywords: +patch pull_requests: +11978 stage: -> patch review ___ Python tracker ___ ___ Python-bugs-

[issue36049] No __repr__() for queue.PriorityQueue and queue.LifoQueue

2019-02-20 Thread Stéphane Wirtel
Stéphane Wirtel added the comment: Just created a PR for this issue and I need to add the tests for the __repr__ method -- ___ Python tracker ___ _

[issue36049] No __repr__() for queue.PriorityQueue and queue.LifoQueue

2019-02-20 Thread Zahash Z
Zahash Z added the comment: I raised this issue after creating a pull request and modifying the source code. so, people who want to create a pull request can sit back and relax cuz I got this -- ___ Python tracker

[issue36049] No __repr__() for queue.PriorityQueue and queue.LifoQueue

2019-02-20 Thread Roundup Robot
Change by Roundup Robot : -- pull_requests: +11980 ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe: https://ma

[issue36049] No __repr__() for queue.PriorityQueue and queue.LifoQueue

2019-02-20 Thread Karthikeyan Singaravelan
Change by Karthikeyan Singaravelan : -- nosy: +rhettinger ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe: htt

[issue36049] No __repr__() for queue.PriorityQueue and queue.LifoQueue

2019-02-20 Thread Rémi Lapeyre
Rémi Lapeyre added the comment: Hi @matrixise, is it really an issue to iterate over all the elements of the deque? __repr__ won't be called on performance sensitive path and we already do this for repr([0]*1), repr({i for i in range(1)}) and repr({i:i for i in range(1)})

[issue36049] No __repr__() for queue.PriorityQueue and queue.LifoQueue

2019-02-20 Thread Stéphane Wirtel
Stéphane Wirtel added the comment: Yep, we have a problem, two PRs for the same issue. I have seen your issue in the bug tracker (not marked as "in progress") and I started to fix it where I have proposed some solutions and a PR. For the next time, maybe you should create the issue, indicate

[issue36049] No __repr__() for queue.PriorityQueue and queue.LifoQueue

2019-02-20 Thread Stéphane Wirtel
Stéphane Wirtel added the comment: @remi.lapeyre In fact, I am not sure about the performance issue but in the code of _collectionsmodule.c#deque_repr we create a PySequence_List, it's a new list. So for me, but maybe I am wrong, we will iterate over the deque container for the creation of t

[issue36049] No __repr__() for queue.PriorityQueue and queue.LifoQueue

2019-02-20 Thread Stéphane Wirtel
Stéphane Wirtel added the comment: static PyObject * deque_repr(PyObject *deque) { PyObject *aslist, *result; ... aslist = PySequence_List(deque); ... if (((dequeobject *)deque)->maxlen >= 0) result = PyUnicode_FromFormat("%s(%R, maxlen=%zd)",

[issue36049] No __repr__() for queue.PriorityQueue and queue.LifoQueue

2019-02-20 Thread Zahash Z
Change by Zahash Z : -- components: +Library (Lib) ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe: https://ma

[issue36049] No __repr__() for queue.PriorityQueue and queue.LifoQueue

2019-02-20 Thread Rémi Lapeyre
Rémi Lapeyre added the comment: Note: when repr do not round trip, I think it's common practice to use brackets: instead of: LifoQueue('a'...'c') Example with Regex from https://docs.python.org/3/howto/regex.html: >>> re.match(r'From\s+', 'From amk Thu May 14 19:12:10 1998')

[issue36049] No __repr__() for queue.PriorityQueue and queue.LifoQueue

2019-02-20 Thread Stéphane Wirtel
Stéphane Wirtel added the comment: Fixed -- ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.pyth

[issue36049] No __repr__() for queue.PriorityQueue and queue.LifoQueue

2019-02-20 Thread Serhiy Storchaka
Change by Serhiy Storchaka : -- assignee: -> rhettinger ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe: http

[issue36049] No __repr__() for queue.PriorityQueue and queue.LifoQueue

2019-02-20 Thread Rémi Lapeyre
Rémi Lapeyre added the comment: See also https://bugs.python.org/issue35889 which add repr to sqlite3.Row -- ___ Python tracker ___

[issue36049] No __repr__() for queue.PriorityQueue and queue.LifoQueue

2019-02-20 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: I guess you hurried to write the code. It has not yet been decided whether to expose the content of the queue in its repr at all. There is no public API for accessing the content of the queue without removing items from the queue, and I think it is intenti

[issue36049] No __repr__() for queue.PriorityQueue and queue.LifoQueue

2019-02-20 Thread Zahash Z
Zahash Z added the comment: If you look at the queue.PriorityQueue class, there is self.queue = [ ]. That's because priority queue uses list data structure to implement the min heap data structure (on which priority queue is based on). So the list can be represented. There is no need to remov

[issue36049] No __repr__() for queue.PriorityQueue and queue.LifoQueue

2019-02-20 Thread Raymond Hettinger
Raymond Hettinger added the comment: [Zahash Z] (Zahash Z)] > If you look at the queue.PriorityQueue class, there is > self.queue = [ ]. We really don't want to expose the internals here. They are subject to change and access to them is guarded by locks. > It has not yet been decided wheth

[issue36049] No __repr__() for queue.PriorityQueue and queue.LifoQueue

2019-02-20 Thread Stéphane Wirtel
Stéphane Wirtel added the comment: Hi @rhettinger Thank you for the review of this issue. -- resolution: rejected -> stage: resolved -> patch review status: closed -> open ___ Python tracker ___

[issue36049] No __repr__() for queue.PriorityQueue and queue.LifoQueue

2019-02-20 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: If you treat the "queue" attribute as a part the public API, just use repr(q.queue) instead of repr(q). -- resolution: -> rejected stage: patch review -> resolved status: open -> closed ___ Python tracker

[issue36049] No __repr__() for queue.PriorityQueue and queue.LifoQueue

2019-02-20 Thread Raymond Hettinger
Raymond Hettinger added the comment: > It has not yet been decided whether to expose the content > of the queue in its repr at all. There is no public API for > accessing the content of the queue without removing items > from the queue, and I think it is intentional. I agree with Serhiy. Le

[issue36049] No __repr__() for queue.PriorityQueue and queue.LifoQueue

2019-02-20 Thread Stéphane Wirtel
Stéphane Wirtel added the comment: Hi @rhettinger and @serhiy Really sorry, I did not see that I have re-opened the issue. -- ___ Python tracker ___ __