タグ

ブックマーク / gfx.hatenadiary.org (3)

  • Should we avoid C implementation? - Islands in the byte stream

    先日のPycon mini JPでは、Tenjinのトークが好評だったようでした*1。 How to Create a Highspeed Template Engine in Python このスライドの中で述べられているのは以下のような事です。 Web Appの実行時間の中でViewコンポーネントが占める割合は意外と大きい テンプレートエンジンをCで実装する必要はない 様々な言語*2のテンプレートエンジンの実行速度を比較してみると、Perlが最速だった Djangoのテンプレートエンジンは遅い このスライド、見せ方が非常にうまいので一見なるほどという感じがしますが、この二番目の「テンプレートエンジンをCで実装する必要はない」という結論には疑問があります。 このスライドの前半にあるような最適化手法は私もずいぶん熱心にやったものです。しかし結局のところスクリプト言語はCには敵わないので、

    Should we avoid C implementation? - Islands in the byte stream
    kzfm
    kzfm 2011/02/01
    Should we avoid C implementation?
  • Pure PerlによるPerl5 Virtual Machineの実装 - Islands in the byte stream (legacy)

    Perl VMの気持ちを知るには、PurePerlで実装してみるとよい。 コード例(PerlVM.pmのコードは記事の末尾にある): #!perl -w use strict; use PerlVM; my $x = shift || 42; PerlVM::call_sv(sub{ print "Hello,", " world!", "\n"; if($x){ print $x, " is true\n"; } else{ print $x, " is false\n"; } }); __END__ 実行結果: $ perl hello.pl Hello, world! 42 is trueむろん、PerlVM::call_sv()の中で引数を呼び出したりはしていない。 Hello, world!くらいならPerlVMの中身も比較的単純だ。そのメカニズムはBモジュールに依存している。B

    Pure PerlによるPerl5 Virtual Machineの実装 - Islands in the byte stream (legacy)
    kzfm
    kzfm 2009/03/29
  • Perlで特異メソッド - Islands in the byte stream (legacy)

    Ruby界隈ではあたりまえのように使われる特異メソッド*1だが,Perlでは組み込みでのサポートはなく,標準モジュールにも特異メソッドを実現するものはない。Class::MOP/Mooseの匿名クラスが似た用途を持っている*2が,オブジェクトの実装型に制約がある。たとえば,以下のコードは動かない。 #!perl -w use strict; use IO::File (); use Moose (); my $anonclass = Moose::Meta::Class->create_anon_class( superclasses => [qw(IO::File)], methods => { hello => sub{ my $self = shift; $self->print("Hello, world!\n"); }, } ); my $io = $anonclass->new

    Perlで特異メソッド - Islands in the byte stream (legacy)
  • 1