Python论坛  - 讨论区

标题:[python-chinese] 能谈谈D语言吗?我来抛个砖

2007年09月21日 星期五 17:28

赵威 zhaowei在pythonid.com
星期五 九月 21 17:28:00 HKT 2007

junyi sun£¬ÄúºÃ£¡ 

¡¡¡¡ÎÒ¶Ô DÓïÑÔ²»ÊǺÜÁ˽⣬µ«ÉÔÓÐһЩ½Ó´¥£¬¸Ð¾õËüµÄÓïÑÔ±¾ÉíÌ«¹ý¸´ÔÓÁË¡£¡£
¿ÉÒÔ˵Ëü×î´óµÄ¸ÄÉƺÍÁÁµã¾ÍÔÚÓÚ¶ÔÄÚ´æʹÓ÷½Ãæ¡£
µ«ÊÇËüµÄһЩÓïÑÔÌØÐԿɲ»±ÈC++¼òµ¥¡£
C++µÄÄ£¿é¶¼ÒѾ­¹»¸´ÔÓÁË¡£¡£

×Ô´ÓÓÃÉÏpythonÒÔÀ´ÎÒʼÖÕ¾õµÃ simple is better


======== 2007-09-21 16:52:40 ÄúÔÚÀ´ÐÅÖÐдµÀ£º ========

½ñÌì¿´¼ûCSDNÉÏÃÍÍÆDÓïÑÔ£¬¾ÍÈ¥ÏÂÔØÁ˸ö±àÒëÆ÷ÍæÍæ¶ù¡£
·¢ÏÖÓÖ¼¸¸öÌصã±È½ÏÎüÒýÎÒ£º

1.²»ÐèÒªÐéÄâ»ú£¬³ÌÐòÌå»ýС
2.ÏñpythonµÄlistÒ»ÑùÓÅÑŵÄarray
3.ÕýÔò±í´ïʽ
4.GC
5.UnicodeÖ§³Ö
6.¿âËäÈ»²»¼°python,javaµÈÅӴ󣬵«std¿âÖÐÒ²´øÁËmd5/thread/socket/regex/zlibµÈ±È½ÏʵÓõĶ«¶«
7.¿çƽ̨

....... 

´ÓÔËÐеÄÐÔÄÜÉÏÀ´Ëµ£¬½ö´ÎÓÚ´¿C¡£
ÏÂÃæÊÇתÔØÒ»¸öBenchmark:
http://dlang.group.javaeye.com/group/topic/524

ÎÒ¸Õ¿ªÊ¼¿´£¬¶ÔDµÄÀí½âÒ²ºÜÓÐÏÞ£¬ÏÈÅ׿éש£¬ÏëÌýÌý¸ßÊÖÃǵĿ´·¨¡£




= = = = = = = = = = = = = = = = = = = = = = 
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡ÖÂ
Àñ£¡

¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡ÕÔÍþ
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡zhaowei在pythonid.com
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡2007-09-21
-------------- 下一部分 --------------
Ò»¸öHTML¸½¼þ±»ÒƳý...
URL: http://python.cn/pipermail/python-chinese/attachments/20070921/01f0eeaa/attachment.htm 

[导入自Mailman归档:http://www.zeuux.org/pipermail/zeuux-python]

2007年09月21日 星期五 17:41

junyi sun ccnusjy在gmail.com
星期五 九月 21 17:41:06 HKT 2007

ȷʵ£¬DÓïÑÔÈç¹ûÑо¿ÉîÈëµÄ»°ÊDZȽϸ´ÔÓ£¬µ«ÊÇÈç¹ûÎÒÃÇÖ»ÓÃËü¿ª·¢Ó¦ÓóÌÐòµÄ»°£¬Æäʵ²»±ØÓõ½ºÜ¶à¸´ÔӵĻúÖÆ¡£

ÌùÒ»¸öSocket ServerµÄ³ÌÐò£º
/*
    D listener written by Christopher E. Miller
    This code is public domain.
    You may use it for any purpose.
    This code has no warranties and is provided 'as-is'.
*/


import std.conv;
import std.socket;


int main(char[][] args)
{
    ushort port;
    if(args.length >= 2)
    {
        port = std.conv.toUshort(args[1]);
    }
    else
    {
        port = 4444;
    }

    Socket listener = new TcpSocket;
    assert(listener.isAlive);
    listener.blocking = false;
    listener.bind(new InternetAddress(port));
    listener.listen(10);
    printf("Listening on port %d.\n", cast(int)port);

    const int MAX_CONNECTIONS = 60;
    SocketSet sset = new SocketSet(MAX_CONNECTIONS + 1); // Room for
listener.
    Socket[] reads;

    for(;; sset.reset())
    {
        sset.add(listener);
        foreach(Socket each; reads)
        {
            sset.add(each);
        }

        Socket.select(sset, null, null);

        int i;
        for(i = 0;; i++)
        {
            next:
            if(i == reads.length)
                break;

            if(sset.isSet(reads[i]))
            {
                char[1024] buf;
                int read = reads[i].receive(buf);
                if(Socket.ERROR == read)
                {
                    printf("Connection error.\n");
                    goto sock_down;
                }
                else if(0 == read)
                {
                    try
                    {
                        //if the connection closed due to an error,
remoteAddress() could fail
                        printf("Connection from %.*s closed.\n",
reads[i].remoteAddress().toString());
                    }
                    catch
                    {
                    }

                    sock_down:
                    reads[i].close(); //release socket resources now

                    //remove from -reads-
                    if(i != reads.length - 1)
                        reads[i] = reads[reads.length - 1];
                    reads = reads[0 .. reads.length - 1];

                    printf("\tTotal connections: %d\n", reads.length);

                    goto next; //-i- is still the next index
                }
                else
                {
                    printf("Received %d bytes from %.*s: \"%.*s\"\n", read,
reads[i].remoteAddress().toString(), buf[0 .. read]);
                }
            }
        }

        if(sset.isSet(listener)) //connection request
        {
            Socket sn;
            try
            {
                if(reads.length < MAX_CONNECTIONS)
                {
                    sn = listener.accept();
                    printf("Connection from %.*s established.\n",
sn.remoteAddress().toString());
                    assert(sn.isAlive);
                    assert(listener.isAlive);

                    reads ~= sn;
                    printf("\tTotal connections: %d\n", reads.length);
                }
                else
                {
                    sn = listener.accept();
                    printf("Rejected connection from %.*s; too many
connections.\n", sn.remoteAddress().toString());
                    assert(sn.isAlive);

                    sn.close();
                    assert(!sn.isAlive);
                    assert(listener.isAlive);
                }
            }
            catch(Exception e)
            {
                printf("Error accepting: %.*s\n", e.toString());

                if(sn)
                    sn.close();
            }
        }
    }

    return 0;
}



On 9/21/07, ÕÔÍþ <zhaowei在pythonid.com> wrote:
>
> junyi sun£¬ÄúºÃ£¡
>  ÎÒ¶Ô DÓïÑÔ²»ÊǺÜÁ˽⣬µ«ÉÔÓÐһЩ½Ó´¥£¬¸Ð¾õËüµÄÓïÑÔ±¾ÉíÌ«¹ý¸´ÔÓÁË¡£¡£
> ¿ÉÒÔ˵Ëü×î´óµÄ¸ÄÉƺÍÁÁµã¾ÍÔÚÓÚ¶ÔÄÚ´æʹÓ÷½Ãæ¡£
> µ«ÊÇËüµÄһЩÓïÑÔÌØÐԿɲ»±ÈC++¼òµ¥¡£
> C++µÄÄ£¿é¶¼ÒѾ­¹»¸´ÔÓÁË¡£¡£
>
> ×Ô´ÓÓÃÉÏpythonÒÔÀ´ÎÒʼÖÕ¾õµÃ simple is better
>
>
> ======== 2007-09-21 16:52:40 ÄúÔÚÀ´ÐÅÖÐдµÀ£º ========
>
>
> ½ñÌì¿´¼ûCSDNÉÏÃÍÍÆDÓïÑÔ£¬¾ÍÈ¥ÏÂÔØÁ˸ö±àÒëÆ÷ÍæÍæ¶ù¡£
> ·¢ÏÖÓÖ¼¸¸öÌصã±È½ÏÎüÒýÎÒ£º
>
> 1.²»ÐèÒªÐéÄâ»ú£¬³ÌÐòÌå»ýС
> 2.ÏñpythonµÄlistÒ»ÑùÓÅÑŵÄarray
> 3.ÕýÔò±í´ïʽ
> 4.GC
> 5.UnicodeÖ§³Ö
> 6.¿âËäÈ»²»¼°python,javaµÈÅӴ󣬵«std¿âÖÐÒ²´øÁËmd5/thread/socket/regex/zlibµÈ±È½ÏʵÓõĶ«¶«
> 7.¿çƽ̨
>
> .......
>
> ´ÓÔËÐеÄÐÔÄÜÉÏÀ´Ëµ£¬½ö´ÎÓÚ´¿C¡£
> ÏÂÃæÊÇתÔØÒ»¸öBenchmark:
> http://dlang.group.javaeye.com/group/topic/524
>
> ÎÒ¸Õ¿ªÊ¼¿´£¬¶ÔDµÄÀí½âÒ²ºÜÓÐÏÞ£¬ÏÈÅ׿éש£¬ÏëÌýÌý¸ßÊÖÃǵĿ´·¨¡£
>
>
>  = = = = = = = = = = = = = = = = = = = = = =
>
> ÖÂ
> Àñ£¡
>
>  ÕÔÍþ
>  zhaowei在pythonid.com
>  2007-09-21
>
>
> _______________________________________________
> python-chinese
> Post: send python-chinese在lists.python.cn
> Subscribe: send subscribe to python-chinese-request在lists.python.cn
> Unsubscribe: send unsubscribe to  python-chinese-request在lists.python.cn
> Detail Info: http://python.cn/mailman/listinfo/python-chinese
>
-------------- 下一部分 --------------
Ò»¸öHTML¸½¼þ±»ÒƳý...
URL: http://python.cn/pipermail/python-chinese/attachments/20070921/9d3c9e31/attachment.htm 

[导入自Mailman归档:http://www.zeuux.org/pipermail/zeuux-python]

2007年09月21日 星期五 17:47

limodou limodou在gmail.com
星期五 九月 21 17:47:21 HKT 2007

建议去专门讨论D语言的地方去讨论,在这里你想得到什么样的结论?

-- 
I like python!
UliPad <>: http://code.google.com/p/ulipad/
My Blog: http://www.donews.net/limodou

[导入自Mailman归档:http://www.zeuux.org/pipermail/zeuux-python]

如下红色区域有误,请重新填写。

    你的回复:

    请 登录 后回复。还没有在Zeuux哲思注册吗?现在 注册 !

    Zeuux © 2025

    京ICP备05028076号