Your message dated Wed, 21 Jan 2015 10:01:05 +0100
with message-id <[email protected]>
and subject line Re: Bug#695811: django_bash_completion slows down bash startup 
by calling /usr/bin/basename 44 times
has caused the Debian Bug report #695811,
regarding django_bash_completion slows down bash startup by calling 
/usr/bin/basename 44 times
to be marked as done.

This means that you claim that the problem has been dealt with.
If this is not the case it is now your responsibility to reopen the
Bug report if necessary, and/or fix the problem forthwith.

(NB: If you are a system administrator and have no idea what this
message is talking about, this may indicate a serious mail system
misconfiguration somewhere. Please contact [email protected]
immediately.)


-- 
695811: http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=695811
Debian Bug Tracking System
Contact [email protected] with problems
--- Begin Message ---
Package: python-django
Version: 1.4.2-2
Tags: patch

/etc/bash_completion.d/django_bash_completion takes about 150ms to source, 
even on a warm cache, primarily because it forks+execs /usr/bin/basename 
44 times.  This significantly slows down interactive logins.

This patch makes it faster by a factor of 5 (and I imagine that a little 
more thought would reduce the time to effectively zero).

--- /etc/bash_completion.d/django_bash_completion
+++ /etc/bash_completion.d/django_bash_completion
@@ -42,10 +42,10 @@
 _python_django_completion()
 {
     if [[ ${COMP_CWORD} -ge 2 ]]; then
-        PYTHON_EXE=$( basename -- ${COMP_WORDS[0]} )
+        PYTHON_EXE=${COMP_WORDS[0]##*/}
         echo $PYTHON_EXE | egrep "python([2-9]\.[0-9])?" >/dev/null 2>&1
         if [[ $? == 0 ]]; then
-            PYTHON_SCRIPT=$( basename -- ${COMP_WORDS[1]} )
+            PYTHON_SCRIPT=${COMP_WORDS[1]##*/}
             echo $PYTHON_SCRIPT | egrep "manage\.py|django-admin(\.py)?" 
>/dev/null 2>&1
             if [[ $? == 0 ]]; then
                 COMPREPLY=( $( COMP_WORDS="${COMP_WORDS[*]:1}" \
@@ -61,7 +61,7 @@
 if command -v whereis &>/dev/null; then
     python_interpreters=$(whereis python | cut -d " " -f 2-)
     for python in $python_interpreters; do
-        pythons="${pythons} $(basename -- $python)"
+        pythons="${pythons} ${python##*/}"
     done
     pythons=$(echo $pythons | tr " " "\n" | sort -u | tr "\n" " ")
 else

Anders

--- End Message ---
--- Begin Message ---
Version: 1.6-1

On Wed, 12 Dec 2012, Anders Kaseorg wrote:
> /etc/bash_completion.d/django_bash_completion takes about 150ms to source, 
> even on a warm cache, primarily because it forks+execs /usr/bin/basename 
> 44 times.  This significantly slows down interactive logins.

This has been fixed a long time ago in Django 1.6-1.

Closing.
-- 
Raphaël Hertzog ◈ Debian Developer

Support Debian LTS: http://www.freexian.com/services/debian-lts.html
Learn to master Debian: http://debian-handbook.info/get/

--- End Message ---
_______________________________________________
Python-modules-team mailing list
[email protected]
http://lists.alioth.debian.org/cgi-bin/mailman/listinfo/python-modules-team

Reply via email to