Py2.3:对集合的反馈 [英] Py2.3: Feedback on Sets

查看:69
本文介绍了Py2.3:对集合的反馈的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经收到很多关于itertools模块的反馈

但是没有听说过关于新套装模块的问题。


*你是不是?因为选择而感到高兴/愤怒和&

作为设置运算符(而不是+和*)?


*是否支持您的工作所需的套装

,如果是这样,那么实施是否足够

强大?


*是否迫切需要其他设定方法,如

Set.powerset()和Set.isdisjoint(s)或现在的

产品是否足够?


*性能是否符合您的要求期待?


*您是否关心套装只能包含可清洗元素?


*对于大多数参数的设计约束怎么样? br />
set方法必须是另一个Set(而不是任何可迭代的)?


*文档是否清楚?你能建议改进吗?


*套装对你的日常工作有帮助还是有需要

很少?

用户反馈对于确定未来方向至关重要

集合(无论是用C实现,更改API,

和/或是否支持语言语法)。 />
Raymond Hettinger

I''ve gotten lots of feedback on the itertools module
but have not heard a peep about the new sets module.

* Are you overjoyed/outraged by the choice of | and &
as set operators (instead of + and *)?

* Is the support for sets of sets necessary for your work
and, if so, then is the implementation sufficiently
powerful?

* Is there a compelling need for additional set methods like
Set.powerset() and Set.isdisjoint(s) or are the current
offerings sufficient?

* Does the performance meet your expectations?

* Do you care that sets can only contain hashable elements?

* How about the design constraint that the argument to most
set methods must be another Set (as opposed to any iterable)?

* Are the docs clear? Can you suggest improvements?

* Are sets helpful in your daily work or does the need arise
only rarely?
User feedback is essential to determining the future direction
of sets (whether it will be implemented in C, change API,
and/or be given supporting language syntax).
Raymond Hettinger


推荐答案

文章< Jp ******** *******@nwrdny03.gnilink.net> ;, Raymond Hettinger写道:
In article <Jp***************@nwrdny03.gnilink.net>, Raymond Hettinger wrote:
我在itertools模块上得到了很多反馈
但是没有听说过新的集合模块。


我不得不说,虽然我已经查看过sets模块并阅读了它的

文档,但我还没有使用它(更多内容如下)。

*你选择的是否喜出望外和&
作为集合运算符(而不是+和*)?


我其实更喜欢| &安培;语法,因为它使我更加直观,因为运算符的工作方式与使用它们时的工作方式完全相同。

二进制数字运算符。

[snip]

*您是否关心套装只能包含可清洗元素?


No.


[snip]

*文档是否清楚?你能建议改进吗?


像大多数Python文档一样,sets模块的文档非常好。

这个例子也有帮助。

*套装对您的日常工作有帮助吗?或者是否需要很少?


我很少明确地需要集合,但有时需要它们提供的逻辑。

例如,当想要连续两个列表以便生成列表时

只有唯一的元素,可以用set逻辑来完成。但是,因为它是另一个用Python编写的模块,而我只需要逻辑我通常不会因为创建Set类的开销而花费b $ b。如果它是更好的集成(即,一个set()内置类型构造函数,如int(),str(),

等)那么我会感觉更少反对使用集合的预订。我知道这个

预订并不是建立在事实上的,但更多的是信任的感觉

内置类型比模块提供的自定义类更多。

用户反馈对于确定集合的未来发展方向至关重要(无论是用C实现,更改API,还是/或给出支持语言语法)。
I''ve gotten lots of feedback on the itertools module
but have not heard a peep about the new sets module.
I would have to say that while I have looked at the sets module and read its
documentation, I have not used it much (more below).
* Are you overjoyed/outraged by the choice of | and &
as set operators (instead of + and *)?
I actually prefer the | & syntax because it makes more intuitive sense to
me, as the operators work identically to how they do when using them as
binary number operators.

[snip]
* Do you care that sets can only contain hashable elements?
No.

[snip]
* Are the docs clear? Can you suggest improvements?
The docs for the sets module, like most of the Python docs, are very good.
The example helps, too.
* Are sets helpful in your daily work or does the need arise
only rarely?
I rarely need sets explicitly, but sometimes need the logic that they offer.
For example, when wanting to concantenate two lists so that the resulting list
only has unique elements, that can be done with set logic. However, as it
is another module written in Python, and I only need the logic I usually don''t
go through with the overhead of creating the Set classes, etc. If it was
better integrated (ie., a set() builtin type constructor like int(), str(),
etc) then I would feel less of a reservation against using sets. I know this
reservation isn''t founded in facts, but more in the feeling of trusting
builtin types more than custom classes provided by a module.
User feedback is essential to determining the future direction
of sets (whether it will be implemented in C, change API,
and/or be given supporting language syntax).




我不知道上面提供的反馈是否有帮助,但你要求它;-)


问候,


Troels Therkelsen



Don''t know if my feedback provided above helps, but you asked for it ;-)

Regards,

Troels Therkelsen


Raymond Hettinger写道:
Raymond Hettinger wrote:
我对itertools模块有很多反馈
*你是否因为选择而感到高兴/愤怒和&
作为集合运算符(而不是+和*)?


我略微偏爱|和& ;.


*是否支持您的工作所需的套装
如果是,那么实施是否足够强大?

*是否迫切需要其他设置方法,如
Set.powerset()和Set.isdisjoint(s),还是现有的
产品足够?


我想象isdisjoint是有用的,虽然它很容易使用

bool(s& t)。

*性能是否符合您的期望?

*您是否关心套装只能包含可清洗元素?

*参数的设计约束怎么样?大多数
设置方法必须是另一个Set(相对于任何可迭代的)?

*文档是否清晰?你能建议改进吗?


是的:在图书馆参考中,s.union(t)的表格条目应该是

说s | t的同义词。而不是重复描述。这是特别正确的,因为从简单的一眼就不清楚

" s.union(t)"与s | t一起使用或s& t,因为它位于

两者之间。更好的是,我会将它更改为三列表

(操作,同义词,结果)。


*这些设置对您的日常工作或是否需要很少?
I''ve gotten lots of feedback on the itertools module
but have not heard a peep about the new sets module.

* Are you overjoyed/outraged by the choice of | and &
as set operators (instead of + and *)?
I slightly favor | and &.

* Is the support for sets of sets necessary for your work
and, if so, then is the implementation sufficiently
powerful?

* Is there a compelling need for additional set methods like
Set.powerset() and Set.isdisjoint(s) or are the current
offerings sufficient?
I imagine isdisjoint would be useful, although it''s easy enough to use
bool(s&t).

* Does the performance meet your expectations?

* Do you care that sets can only contain hashable elements?

* How about the design constraint that the argument to most
set methods must be another Set (as opposed to any iterable)?

* Are the docs clear? Can you suggest improvements?
Yeah: in the library reference, the table entry for s.union(t) should
say "synonym of s|t" instead of repeating the description. This is
especially true because it''s not clear from a simple glance whether
"s.union(t)" goes with "s|t" or "s&t", because it sits right between
the two. Better yet, I would change it to a three-column table
(operation, synonym, result).

* Are sets helpful in your daily work or does the need arise
only rarely?




我还没有用过套装(或Python 2.3),但我希望用它们来/>
很多。但是,我想我的典型用途是对

会员资格进行有效测试。我现在有六个地方可以使用字典
现金



-

CARL BANKS

你没有运行Microsoft Windows。 Microsoft Windows运行你。



I haven''t used sets yet (or Python 2.3), but I expect to use them a
lot. However, I imagine my typical use would be efficient testing for
membership. I have maybe half a dozen places where I use a dictionary
for that now.

--
CARL BANKS
"You don''t run Microsoft Windows. Microsoft Windows runs you."


Raymond Hettinger写道:


首先,感谢你的工作,我需要在我的工作中一直使用套装

。我写了自己的

(简单化)实现但是从那时起分发程序时又增加了另一层

的头痛

我必须分发多个模块。


有时我在每个

大模块中都有一个小集合功能。很傻。对我而言,套装是非常有用的

另外。
Raymond Hettinger wrote:

First of all, thanks for the work on it, I need to use sets
in my work all the time. I had written my own
(simplistic) implementation but that adds another layer
of headaches when distributing programs since then
I have to distribute multiple modules.

Sometimes I ended up with a little set function in every
big module. Pretty silly. For me sets are a greatly useful
addition.
*是否支持你工作所需的套装
,如果是的话,那么实施是否足够强大?


我经常需要的一种模式是从序列中删除

的重复项。我不知道这是一个经常使用的模式,以确保API更改,对我来说,如果我可以获得的内容是最有用的。立即设置为一个序列,而不必明确地编码它。

*你是否因为选择而感到高兴/愤怒和& as
设置运算符(而不是+和*)?


我认为既然你有 - 作为一个差异运算符它

也有意义也有+作为联合运算符。没有任何东西

远离|。 &操作员是正确的,*不合适

IMO。

*你是否关心那些套装只能包含可清洗的元素?


我真的不在乎,另一方面,调用

类HashSet可能会更好,这样它就可以立即传达出来它使用散列

来存储元素。

*文档是否清晰?你能建议改进吗?


我想知道在构造函层级别指定类的不变性

是否更好。


然后是更新方法。感觉有点多余

因为有一个add()方法似乎在做同样的事情

只有add()一次只添加一个元素。

是否可以使用add()处理所有添加,可迭代或

,然后完全废弃更新()。


然后只是通过查看文档,感觉有点混乱

有discard()和remove()基本上做同样的事情,但只有一个

他们提出例外。哪一个?我已经忘了我不知道

我喜欢哪一个。


我不明白的另一个方面,
$之间有什么区别b $ b update()和union_update()。


long -ded方法名称,例如difference_update()也感觉

多余,当一个人可以实现与 - =运算符相同。我将会丢弃这些,而是​​在文档中显示如何使用运算符完成这些

。会大大削减文档,

和明显的复杂性。


我很喜欢拥有最少数量的方法,只要它

很容易获得结果。


例如x.issubset(y)等方法与bool(xy)相同所以可能

不是所有必要的,只是一个想法。

*套装对你的日常工作有帮助还是很少需要?
* Is the support for sets of sets necessary for your work
and, if so, then is the implementation sufficiently
powerful?
One pattern that I constantly need is to remove duplicates from
a sequence. I don''t know if this an often enough used pattern to
warrant an API change, for me it would be most useful if I could
get the contents of a set as a sequence right away, without having to
explicitly code it.
* Are you overjoyed/outraged by the choice of | and & as
set operators (instead of + and *)?
I think that since you have have - as a difference operator it
would make sense to also have + as a union operator. Takes nothing
away from |. The & operator is the right one, * would not be appropriate
IMO.
* Do you care that sets can only contain hashable elements?
I don''t really care, on the other hand, it might be better to call the
class HashSet, so that it conveys right away that it uses hashing
to store the elements.
* Are the docs clear? Can you suggest improvements?
I wondered whether it would be better to specify the immutability
of the class at the constructor level.

Then there is the update method. It feels a little bit redundant
since there is an add() method that seems to be doing the same thing
only that add() adds only one element at a time.
Would it be possible to have add() handle all additions, iterable or
not, then scrap update() altogether.

Then just by looking at the docs, it feels a little bit confusing to
have discard() and remove() do essentially the same thing but only one
of them raising an exception. Which one? I already forgot. I don''t know
which one I would prefer though.

Another aspect that I did not understand, what is difference between
update() and union_update().

The long winded method names, such as difference_update() also feel
redundant when one can achieve the same thing with the -= operator. I
would drop these and instead show in the docs how to accomplish these
with the operators. Would considerably cut down on the documentation,
and apparent complexity.

I''m a big fan of having the minimal number of methods as long it is
easy to obtain the result.

For example methods like x.issubset(y) is the same as bool(x-y) so may
not be all that necessary, just a thought.
* Are sets helpful in your daily work or does the need arise
only rarely?




我经常使用它们它们非常有用。


再次感谢,


Istvan。



I use them very often and they are extremely useful.

thanks again,

Istvan.


这篇关于Py2.3:对集合的反馈的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆