From: Seweryn Kokot <sewkokot@gmail.com>
To: help-gnu-emacs@gnu.org
Subject: Re: processing a large buffer contents to a hash table
Date: Fri, 09 Jan 2009 18:59:45 +0100 [thread overview]
Message-ID: <87vdsouzqm.fsf@poczta.po.opole.pl> (raw)
In-Reply-To: 1231520831.329403@arno.fh-trier.de
Andreas Politz <politza@fh-trier.de> writes:
> Seweryn Kokot wrote:
>> Hello,
>>
>> I'm trying to write a function in elisp which returns word frequency of
>> a buffer content . It works but for a large file
>> (around 250 000 words) it takes 15 seconds, while a similar function in python
>> takes 4s.
>>
>> Here is the function which process a buffer word by word and write word
>> frequency to a hash table.
>>
>> (defun word-frequency-process-buffer ()
>> (interactive)
>> (let ((buffer (current-buffer)) bounds beg end word)
>> (save-excursion
>> (goto-char (point-min))
>> (while (re-search-forward "\\<[[:word:]]+\\>" nil t)
> (word-frequency-incr (downcase (match-string 0))))))
>
> ...should do the same. (?)
> More specific, I think bounds-of-thing-at-point is
> your bottleneck. And try to compile everything.
>
Indeed it helps a lot.
Now it also takes 4s to process this big file!
Thanks.
--
regards,
Seweryn
next prev parent reply other threads:[~2009-01-09 17:59 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <mailman.4415.1231519828.26697.help-gnu-emacs@gnu.org>
2009-01-09 17:06 ` processing a large buffer contents to a hash table Andreas Politz
2009-01-09 17:59 ` Seweryn Kokot [this message]
2009-01-09 17:47 ` Xah Lee
2009-01-09 16:56 Seweryn Kokot
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87vdsouzqm.fsf@poczta.po.opole.pl \
--to=sewkokot@gmail.com \
--cc=help-gnu-emacs@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).