From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: "Basil L. Contovounesios" via "Bug reports for GNU Emacs, the Swiss army knife of text editors" Newsgroups: gmane.emacs.bugs Subject: bug#58338: 29.0.50; mapatoms called on more elements than in obarray? Date: Thu, 06 Oct 2022 22:35:17 +0300 Message-ID: <87h70gu4ne.fsf@tcd.ie> References: <87ilkxlygs.fsf@posteo.net> <877d1cn77o.fsf@posteo.net> <8735c0n6vp.fsf@posteo.net> <4dd5f196-0d36-b232-7c02-24a27230753e@gmail.com> <87mta8lr9c.fsf@posteo.net> Reply-To: "Basil L. Contovounesios" Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="2877"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Cc: philipk@posteo.net To: 58338@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Thu Oct 06 21:36:36 2022 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1ogWfb-0000cp-Mp for geb-bug-gnu-emacs@m.gmane-mx.org; Thu, 06 Oct 2022 21:36:35 +0200 Original-Received: from localhost ([::1]:42744 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ogWfa-0002Lp-Jh for geb-bug-gnu-emacs@m.gmane-mx.org; Thu, 06 Oct 2022 15:36:34 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:45620) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ogWf6-0002Lb-Lk for bug-gnu-emacs@gnu.org; Thu, 06 Oct 2022 15:36:06 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:34515) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1ogWf4-0005Al-PH for bug-gnu-emacs@gnu.org; Thu, 06 Oct 2022 15:36:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1ogWf4-0003AV-7R for bug-gnu-emacs@gnu.org; Thu, 06 Oct 2022 15:36:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: "Basil L. Contovounesios" Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Thu, 06 Oct 2022 19:36:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 58338 X-GNU-PR-Package: emacs Original-Received: via spool by 58338-submit@debbugs.gnu.org id=B58338.166508493112140 (code B ref 58338); Thu, 06 Oct 2022 19:36:02 +0000 Original-Received: (at 58338) by debbugs.gnu.org; 6 Oct 2022 19:35:31 +0000 Original-Received: from localhost ([127.0.0.1]:33593 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ogWeZ-00039k-1O for submit@debbugs.gnu.org; Thu, 06 Oct 2022 15:35:31 -0400 Original-Received: from mail-ej1-f51.google.com ([209.85.218.51]:45778) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ogWeT-00039H-Ru for 58338@debbugs.gnu.org; Thu, 06 Oct 2022 15:35:30 -0400 Original-Received: by mail-ej1-f51.google.com with SMTP id sc25so711150ejc.12 for <58338@debbugs.gnu.org>; Thu, 06 Oct 2022 12:35:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tcd.ie; s=google21; h=mime-version:user-agent:message-id:date:references:in-reply-to :subject:cc:to:from:from:to:cc:subject:date:message-id:reply-to; bh=cqXDhPRJ0cnygGas0bQbXPuYhTHmGseHQSiDHrWfxEY=; b=a66CCMlEWJcWZEIAit0yVBpJS1rhRtMrpY+vFvcew4rNJtSCoqFFaom9RJ+Bsmme2f 2mhzHnY1SlMkqEf4Gu8yRNQkavR8G4PFUTHeskL79d2jxwIbK7y+JSG81oMEsTBijBHW JxICqLVL7GyWTzq0MZe6hMK4bp+F7kKTLwZz5mem/KH/iqmm7bSBcTPIEaEWbvEzbOdm rQeUM5lMvWBBZp0Fd9R890JssIUrLBf9pn99IBRb329nyMYHd/TYt6i8L0nrWI0M6Pve BJhtput57b6iqer5BWGQxJdPea5vfOx1Pp2AEvmclMEtsRrQSSl0CkerDwuRKKMp8YX8 MaXQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=mime-version:user-agent:message-id:date:references:in-reply-to :subject:cc:to:from:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=cqXDhPRJ0cnygGas0bQbXPuYhTHmGseHQSiDHrWfxEY=; b=FZFATqf1S4+hn+T4QeFJ9ZilXkFGv0rbBcsUf/B0cJWblJD0tJ4A/IZU5weqOi+IRI Gi5ich5wxLu7+vGrBGSx/qyVyXc0eYN3LTmWos5j3qlwV2e3pWF32hFLfL6VuwoGEAPl wCiHA8JgetiKettPlbe7oQJRQJLfBx18jrnKSLJ3vleG2Am1XZYdNEAJzOkcrta0wKaf TPV4UqQfKKwYlFtKtPMOCElPNwKgMhNMiicWVqelPJaNx+jFufaflXvDpL9Oo6tBeQHp 0H1MZwt58y4SEJxBExEoRYHphvAucGZQ8A0hysItSHtdzONuMrs+drRD3nCj92pX4hfm nTgA== X-Gm-Message-State: ACrzQf376JlGs4wj2P/8g818+16No2vRa7D1SuyW2PtjmKGMX5c0NHDm Q0dZFKdww4ZwRM8dAWeov6Eh5dzwSbGO6A== X-Google-Smtp-Source: AMsMyM7s28LmOYH5+urwxrNk3h1RbSMlN6fWe5TSiJPbga3aLekl9IpQm7qHIAuP+m9RNwXaRcU5ZA== X-Received: by 2002:a17:907:a407:b0:783:5465:902 with SMTP id sg7-20020a170907a40700b0078354650902mr1201979ejc.35.1665084919725; Thu, 06 Oct 2022 12:35:19 -0700 (PDT) Original-Received: from localhost ([2a02:587:326a:a129:e754:c019:8715:df11]) by smtp.gmail.com with ESMTPSA id me8-20020a170906aec800b00781b589a1afsm95770ejb.159.2022.10.06.12.35.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 06 Oct 2022 12:35:18 -0700 (PDT) In-Reply-To: <87mta8lr9c.fsf@posteo.net> (Philip Kaludercic's message of "Thu, 06 Oct 2022 18:51:43 +0000") X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.io gmane.emacs.bugs:244710 Archived-At: Philip Kaludercic [2022-10-06 18:51 +0000] wrote: > OK, then I'll close the report. But if I am not supposed to use the > obarrays, what would you recommend if I want to count the number of > known symbols? (Context: I am trying to detect all variables defined > in a package, and since that takes a while I wrapped the `mapatoms' call in > a progress reporter, that needs a maximal value). An obarray is just a flat vector of symbols, but each symbol itself is actually implemented in C as a singly linked list of symbols (see struct Lisp_Symbol). If you inspect mapatoms you'll see it indeed traverses each symbol chain in each vector bucket. > What is even more vexing is that the deceptively named `obarray-size' > just calls `length'. Is there no better way to count the number of > entries in a obarray, as `hash-table-count' does for hash tables? Thus I don't think it's possible to know ahead of time the exact number of symbols interned in a given obarray without traversing the whole structure with mapatoms (but maybe I'm forgetting something obvious). For this and associated reasons hash tables are generally preferred over obarrays as an associative data structure, but for variables/symbols we're stuck with obarray. HTH, -- Basil