python STL? [英] python STL?

查看:113
本文介绍了python STL?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



最近以强大的

动态语言引入了编程的乐趣(去蛇吧!)我定期重新思考C ++的哪些部分我/ br / >
仍然怀念。我真正喜欢的一件事是C ++的泛型 - 我认为

它们是强类型系统的唯一强大好处。我想知道在
Python中实现类似STL算法的可能性以及我想不出没有kludge的一件事

是STL依赖的对象比较,而这又是

依赖于类型和函数(<)重载。有没有办法在python中实现

类似的东西(缺少多方法?)。

python字典对象如何允许任意键类型?在内部

使用引用的地址来强制树木订购?

谢谢,

max。

解决方案

>最近在强大的

动态语言中引入了编程的乐趣(去蛇!)我会定期重新思考C ++的哪些部分仍然会遗漏。我真正喜欢的一件事是C ++的泛型 - 我认为它们是强类型系统的唯一强大好处。我想知道在Python中实现类似STL算法的可能性以及我想不出没有kludge做的事情
是STL依赖的对象比较,反过来
依赖于类型和功能(<)重载。有没有办法在python中实现类似的东西(缺少多方法?)。
python字典对象如何允许任意键类型?是在内部
使用引用的地址来强制树木订购?
谢谢,
最大




Hi Max,


你能举一个你想念的更具体的例子吗?


-Dave


std :: sort - 适用于任何有序的对象集合(你只需定义

你自己的运算符<如果你需要根据一些奇怪的标准进行排序)


" Dave Brueck" <哒** @ pythonapocrypha.com>在留言中写道

新闻:ma ************************************ @python .org ...

最近以强大的动态语言介绍了编程的乐趣(去蛇!)我定期重新考虑哪些部分C ++我仍然想念。我真正喜欢的一件事是C ++的泛型 - 我认为它们是强类型系统的唯一强大好处。我想知道在Python中实现类似STL算法的可能性以及我想不出没有kludge做的事情
是STL依赖的对象比较,反过来
依赖于类型和功能(<)重载。有没有办法在python中实现类似的东西(缺少多方法?)。
python字典对象如何允许任意键类型?是在内部
使用引用的地址强加树的排序?
谢谢,
最大



你好Max,

你能否举一个你想念的更具体的例子?

-Dave



11月14日星期五2003 21:07:16 GMT,xam < ma@Bell.com>写道:

std :: sort - 适用于任何有序的对象集合(您只需定义
您自己的运算符<如果您需要根据一些奇怪的标准进行排序)


标准排序(lt)函数中存在特定的ALREADy,

其可选参数lt is anyless than你关心的运营商

定义。


" Dave Brueck" <哒** @ pythonapocrypha.com>在消息中写道
新闻:ma ************************************ @ pytho n。 org ...

>最近被介绍给强大的编程乐趣
>动态语言(去蛇!)我定期重新思考C ++的哪些部分我是
>还是想念。我真正喜欢的一件事是C ++的泛型 - 我认为
>它们是强类型系统的唯一强大好处。我是
>想知道在
>中实现类似STL算法的可能性。 Python和没有kludge我想不到的一件事
>是STL依赖的对象比较,反过来
>依赖于类型和函数(<)重载。有没有办法实施
> python中有类似的东西(缺少多方法?)。如何
> python字典对象允许任意键类型?在内部
>使用引用''地址强制树排序?
>谢谢,
> max。




你能举一个你想念的更具体的例子吗?

-Dave




Hi,
being recently introduced to the joys of programming in a powerful
dynamic language (go snake!) I periodically rethink which parts of C++ I
still miss. One thing I really enjoy is the generics of C++ - i think
they are the single strong benefit of a strongly typed system. I was
wondering about the possibility of implementing STL-like algorithms in
Python and the one thing that I cannot think of doing without a kludge
is the object comparsion that so much of STL relies on, which in turn
relies on types and function(<) overloading. Is there a way to implement
something similar in python (short of multimethods?). How does the
python dictionary object allow arbitrary key types? Is in internally
using the references'' addresses to impose the tree ordering?
thanks,
max.

解决方案

> being recently introduced to the joys of programming in a powerful

dynamic language (go snake!) I periodically rethink which parts of C++ I
still miss. One thing I really enjoy is the generics of C++ - i think
they are the single strong benefit of a strongly typed system. I was
wondering about the possibility of implementing STL-like algorithms in
Python and the one thing that I cannot think of doing without a kludge
is the object comparsion that so much of STL relies on, which in turn
relies on types and function(<) overloading. Is there a way to implement
something similar in python (short of multimethods?). How does the
python dictionary object allow arbitrary key types? Is in internally
using the references'' addresses to impose the tree ordering?
thanks,
max.



Hi Max,

Could you give a more specific example of what you miss?

-Dave


std::sort - works on any well-ordered object collection (you just define
your own operator< if you need to sort based on some weird criteria)

"Dave Brueck" <da**@pythonapocrypha.com> wrote in message
news:ma************************************@python .org...

being recently introduced to the joys of programming in a powerful
dynamic language (go snake!) I periodically rethink which parts of C++ I
still miss. One thing I really enjoy is the generics of C++ - i think
they are the single strong benefit of a strongly typed system. I was
wondering about the possibility of implementing STL-like algorithms in
Python and the one thing that I cannot think of doing without a kludge
is the object comparsion that so much of STL relies on, which in turn
relies on types and function(<) overloading. Is there a way to implement
something similar in python (short of multimethods?). How does the
python dictionary object allow arbitrary key types? Is in internally
using the references'' addresses to impose the tree ordering?
thanks,
max.



Hi Max,

Could you give a more specific example of what you miss?

-Dave



On Fri, 14 Nov 2003 21:07:16 GMT, "xam" <ma@Bell.com> wrote:

std::sort - works on any well-ordered object collection (you just define
your own operator< if you need to sort based on some weird criteria)

That particular one ALREADy exists in the standard sort(lt) funciton,
whose optional argument lt is any "less than" operator you care to
define.

"Dave Brueck" <da**@pythonapocrypha.com> wrote in message
news:ma************************************@pytho n.org...

> being recently introduced to the joys of programming in a powerful
> dynamic language (go snake!) I periodically rethink which parts of C++ I
> still miss. One thing I really enjoy is the generics of C++ - i think
> they are the single strong benefit of a strongly typed system. I was
> wondering about the possibility of implementing STL-like algorithms in
> Python and the one thing that I cannot think of doing without a kludge
> is the object comparsion that so much of STL relies on, which in turn
> relies on types and function(<) overloading. Is there a way to implement
> something similar in python (short of multimethods?). How does the
> python dictionary object allow arbitrary key types? Is in internally
> using the references'' addresses to impose the tree ordering?
> thanks,
> max.



Hi Max,

Could you give a more specific example of what you miss?

-Dave




这篇关于python STL?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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