ruby-core@ruby-lang.org archive (unofficial mirror)
 help / color / mirror / Atom feed
* [ruby-core:93944] [Ruby master Bug#16026] `Set#count` performance issues
       [not found] <redmine.issue-16026.20190727060019@ruby-lang.org>
@ 2019-07-27  6:00 ` samuel
  2019-07-27  7:09 ` [ruby-core:93945] " hanmac
                   ` (6 subsequent siblings)
  7 siblings, 0 replies; 8+ messages in thread
From: samuel @ 2019-07-27  6:00 UTC (permalink / raw
  To: ruby-core

Issue #16026 has been reported by ioquatix (Samuel Williams).

----------------------------------------
Bug #16026: `Set#count` performance issues
https://bugs.ruby-lang.org/issues/16026

* Author: ioquatix (Samuel Williams)
* Status: Open
* Priority: Normal
* Assignee: knu (Akinori MUSHA)
* Target version: 
* ruby -v: 
* Backport: 2.5: UNKNOWN, 2.6: UNKNOWN
----------------------------------------
`Set#size` is O(1), but `Set#count` is O(N).

I would like to add `alias count size` to `class Set`

Is it okay?



-- 
https://bugs.ruby-lang.org/

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [ruby-core:93945] [Ruby master Bug#16026] `Set#count` performance issues
       [not found] <redmine.issue-16026.20190727060019@ruby-lang.org>
  2019-07-27  6:00 ` [ruby-core:93944] [Ruby master Bug#16026] `Set#count` performance issues samuel
@ 2019-07-27  7:09 ` hanmac
  2019-07-27 16:15 ` [ruby-core:93950] " samuel
                   ` (5 subsequent siblings)
  7 siblings, 0 replies; 8+ messages in thread
From: hanmac @ 2019-07-27  7:09 UTC (permalink / raw
  To: ruby-core

Issue #16026 has been updated by Hanmac (Hans Mackowiak).


technically `Set#count` comes from `Enumerable`, where it has support for this too

```
enum.count(item)           -> int
enum.count { |obj| block } -> int
```

so i don't think Set should make `#count` work like `#size`

----------------------------------------
Bug #16026: `Set#count` performance issues
https://bugs.ruby-lang.org/issues/16026#change-80131

* Author: ioquatix (Samuel Williams)
* Status: Open
* Priority: Normal
* Assignee: knu (Akinori MUSHA)
* Target version: 
* ruby -v: 
* Backport: 2.5: UNKNOWN, 2.6: UNKNOWN
----------------------------------------
`Set#size` is O(1), but `Set#count` is O(N).

I would like to add `alias count size` to `class Set`

Is it okay?



-- 
https://bugs.ruby-lang.org/

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [ruby-core:93950] [Ruby master Bug#16026] `Set#count` performance issues
       [not found] <redmine.issue-16026.20190727060019@ruby-lang.org>
  2019-07-27  6:00 ` [ruby-core:93944] [Ruby master Bug#16026] `Set#count` performance issues samuel
  2019-07-27  7:09 ` [ruby-core:93945] " hanmac
@ 2019-07-27 16:15 ` samuel
  2019-07-28 15:20 ` [ruby-core:93959] " jean.boussier
                   ` (4 subsequent siblings)
  7 siblings, 0 replies; 8+ messages in thread
From: samuel @ 2019-07-27 16:15 UTC (permalink / raw
  To: ruby-core

Issue #16026 has been updated by ioquatix (Samuel Williams).


I understand and I agree with your logic.

Maybe it's worth considering, `#count` with no arguments can invoke `#size`. What do you think?

----------------------------------------
Bug #16026: `Set#count` performance issues
https://bugs.ruby-lang.org/issues/16026#change-80140

* Author: ioquatix (Samuel Williams)
* Status: Open
* Priority: Normal
* Assignee: knu (Akinori MUSHA)
* Target version: 
* ruby -v: 
* Backport: 2.5: UNKNOWN, 2.6: UNKNOWN
----------------------------------------
`Set#size` is O(1), but `Set#count` is O(N).

I would like to add `alias count size` to `class Set`

Is it okay?



-- 
https://bugs.ruby-lang.org/

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [ruby-core:93959] [Ruby master Bug#16026] `Set#count` performance issues
       [not found] <redmine.issue-16026.20190727060019@ruby-lang.org>
                   ` (2 preceding siblings ...)
  2019-07-27 16:15 ` [ruby-core:93950] " samuel
@ 2019-07-28 15:20 ` jean.boussier
  2019-08-13  1:04 ` [ruby-core:94316] " samuel
                   ` (3 subsequent siblings)
  7 siblings, 0 replies; 8+ messages in thread
From: jean.boussier @ 2019-07-28 15:20 UTC (permalink / raw
  To: ruby-core

Issue #16026 has been updated by byroot (Jean Boussier).


> Maybe it's worth considering, #count with no arguments can invoke #size. What do you think?

Since it's what Array does (`rb_ary_count `), it would make sense to do the same in `set.rb` IMHO.


----------------------------------------
Bug #16026: `Set#count` performance issues
https://bugs.ruby-lang.org/issues/16026#change-80150

* Author: ioquatix (Samuel Williams)
* Status: Open
* Priority: Normal
* Assignee: knu (Akinori MUSHA)
* Target version: 
* ruby -v: 
* Backport: 2.5: UNKNOWN, 2.6: UNKNOWN
----------------------------------------
`Set#size` is O(1), but `Set#count` is O(N).

I would like to add `alias count size` to `class Set`

Is it okay?



-- 
https://bugs.ruby-lang.org/

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [ruby-core:94316] [Ruby master Bug#16026] `Set#count` performance issues
       [not found] <redmine.issue-16026.20190727060019@ruby-lang.org>
                   ` (3 preceding siblings ...)
  2019-07-28 15:20 ` [ruby-core:93959] " jean.boussier
@ 2019-08-13  1:04 ` samuel
  2019-08-13 11:19 ` [ruby-core:94322] " knu
                   ` (2 subsequent siblings)
  7 siblings, 0 replies; 8+ messages in thread
From: samuel @ 2019-08-13  1:04 UTC (permalink / raw
  To: ruby-core

Issue #16026 has been updated by ioquatix (Samuel Williams).


I was okay with changing my implementation to use `#size` - which is what I've done. However, I don't think there is anything wrong with optimising this use case if it doesn't add any overhead to existing use case. Because `Array` does it too, it makes me think it's not a completely stupid idea.

----------------------------------------
Bug #16026: `Set#count` performance issues
https://bugs.ruby-lang.org/issues/16026#change-80677

* Author: ioquatix (Samuel Williams)
* Status: Open
* Priority: Normal
* Assignee: knu (Akinori MUSHA)
* Target version: 
* ruby -v: 
* Backport: 2.5: UNKNOWN, 2.6: UNKNOWN
----------------------------------------
`Set#size` is O(1), but `Set#count` is O(N).

I would like to add `alias count size` to `class Set`

Is it okay?



-- 
https://bugs.ruby-lang.org/

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [ruby-core:94322] [Ruby master Bug#16026] `Set#count` performance issues
       [not found] <redmine.issue-16026.20190727060019@ruby-lang.org>
                   ` (4 preceding siblings ...)
  2019-08-13  1:04 ` [ruby-core:94316] " samuel
@ 2019-08-13 11:19 ` knu
  2019-08-13 13:48 ` [ruby-core:94325] " hanmac
  2019-09-06 23:06 ` [ruby-core:94813] " samuel
  7 siblings, 0 replies; 8+ messages in thread
From: knu @ 2019-08-13 11:19 UTC (permalink / raw
  To: ruby-core

Issue #16026 has been updated by knu (Akinori MUSHA).


I agree that the `return size if !block_given? && respond_to?(:size)` logic should belong to Enumerable.

----------------------------------------
Bug #16026: `Set#count` performance issues
https://bugs.ruby-lang.org/issues/16026#change-80709

* Author: ioquatix (Samuel Williams)
* Status: Open
* Priority: Normal
* Assignee: knu (Akinori MUSHA)
* Target version: 
* ruby -v: 
* Backport: 2.5: UNKNOWN, 2.6: UNKNOWN
----------------------------------------
`Set#size` is O(1), but `Set#count` is O(N).

I would like to add `alias count size` to `class Set`

Is it okay?



-- 
https://bugs.ruby-lang.org/

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [ruby-core:94325] [Ruby master Bug#16026] `Set#count` performance issues
       [not found] <redmine.issue-16026.20190727060019@ruby-lang.org>
                   ` (5 preceding siblings ...)
  2019-08-13 11:19 ` [ruby-core:94322] " knu
@ 2019-08-13 13:48 ` hanmac
  2019-09-06 23:06 ` [ruby-core:94813] " samuel
  7 siblings, 0 replies; 8+ messages in thread
From: hanmac @ 2019-08-13 13:48 UTC (permalink / raw
  To: ruby-core

Issue #16026 has been updated by Hanmac (Hans Mackowiak).


it might not be able to be generic in Enumerable

for example an Widget might be Enumerable with the child widgets, but its size would be `[width, height]`

----------------------------------------
Bug #16026: `Set#count` performance issues
https://bugs.ruby-lang.org/issues/16026#change-80713

* Author: ioquatix (Samuel Williams)
* Status: Open
* Priority: Normal
* Assignee: knu (Akinori MUSHA)
* Target version: 
* ruby -v: 
* Backport: 2.5: UNKNOWN, 2.6: UNKNOWN
----------------------------------------
`Set#size` is O(1), but `Set#count` is O(N).

I would like to add `alias count size` to `class Set`

Is it okay?



-- 
https://bugs.ruby-lang.org/

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [ruby-core:94813] [Ruby master Bug#16026] `Set#count` performance issues
       [not found] <redmine.issue-16026.20190727060019@ruby-lang.org>
                   ` (6 preceding siblings ...)
  2019-08-13 13:48 ` [ruby-core:94325] " hanmac
@ 2019-09-06 23:06 ` samuel
  7 siblings, 0 replies; 8+ messages in thread
From: samuel @ 2019-09-06 23:06 UTC (permalink / raw
  To: ruby-core

Issue #16026 has been updated by ioquatix (Samuel Williams).

Status changed from Open to Rejected

Given the discussion, I'm okay if we just reject this feature. @knu it's up to you if you want to implement it or not. Even thought it can make sense from one POV, the correct solution for most users is just to use `#size` when it's available, rather than making `#count` more complicated implementation (and potentially slower).

Ultimately, it was my fault for not understanding `#count`.

----------------------------------------
Bug #16026: `Set#count` performance issues
https://bugs.ruby-lang.org/issues/16026#change-81434

* Author: ioquatix (Samuel Williams)
* Status: Rejected
* Priority: Normal
* Assignee: knu (Akinori MUSHA)
* Target version: 
* ruby -v: 
* Backport: 2.5: UNKNOWN, 2.6: UNKNOWN
----------------------------------------
`Set#size` is O(1), but `Set#count` is O(N).

I would like to add `alias count size` to `class Set`

Is it okay?



-- 
https://bugs.ruby-lang.org/

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2019-09-06 23:07 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <redmine.issue-16026.20190727060019@ruby-lang.org>
2019-07-27  6:00 ` [ruby-core:93944] [Ruby master Bug#16026] `Set#count` performance issues samuel
2019-07-27  7:09 ` [ruby-core:93945] " hanmac
2019-07-27 16:15 ` [ruby-core:93950] " samuel
2019-07-28 15:20 ` [ruby-core:93959] " jean.boussier
2019-08-13  1:04 ` [ruby-core:94316] " samuel
2019-08-13 11:19 ` [ruby-core:94322] " knu
2019-08-13 13:48 ` [ruby-core:94325] " hanmac
2019-09-06 23:06 ` [ruby-core:94813] " samuel

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).